Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 5 months ago.
Q's about FRDM-K64 USB Serial & UART operation/coupling
I am using a FRDM-K64F board with the GCC compiler (frdm-k64f-gcc 2.0.0) and mbed/yotta, all stock nothing changed. I am attempting to implement a monitor program using USBTX/USBRX to interact with a user and UART0 to send data to an attached device. I have few questions:
1) when using UART0, I noticed that PTA1 and PTA2 are not defined in 'yotta_modules/mbed-hal-frdm-k64f/source/PeripheralPins.c'. I added the following to the respective tables PinMap_UART_TX and PinMap_UART_RX: {PTA2 , UART_0, 3} TX Pin {PTA1, UART_0, 3} RX Pin This appears to rectify the problem of being able to use the pin (at least it compiles cleanly). Is there a reason this definition was omitted?
2) To test that the UART0/PTA2/PTA1 was working, I jumped PTA2 to PTA1 so it was simply looped back onto itself. In my code I am using the following:
#include "mbed-drivers/mbed.h" Serial uart(PTA2, PTA1); Serial pc(USBTX, USBRX); void rxIRQ(void) { extern microrl_t *prl; if( pc.readable() ) { pc.putc('P'); while( pc.readable() ) microrl_insert_char(prl, pc.getc() ); } if( uart.readable() ) { pc.putc('U'); while( pc.readable() ) pc.putc(uart.getc()); } } void serialInit(void) { void rxIRQ(void); pc.baud(9600); uart.baud(9600); uart.attach(&rxIRQ,Serial::RxIrq); }
The reason this may not be working is because USBTX/USBRX seems tied to UART0 functionality, is there anyway to decouple the two so that you still have the ability to use USBTX/RX and the UART0 function?
1 Answer
7 years, 2 months ago.
(USBTX,USBRX) is (PTB17,PTB16) = UART0. When you want to use USB-serial, can use only UART1/2/3/4. UART1 is connected open-SDA, but UART1(PTC4,PTC3) is usable. Note.: UART2/3/4 has no buffer.