I have been trying to get two FRDM K64f boards to communicate using UART3 through pins PTC16 and PTC17. I have been using the uart_interrupt_polling example from KSDK, but I'm not receiving anything. I've changed the code to use UART3, and one of the boards is sending at first, while the other is receiving. I've tried connecting matching pins and crossing the pins. Is there a setting I'm missing or another hardware connection I need to make?
Hi, Timothy,
I think it is okay to connect the PTC16 of one FRDM-K64 to PTC17 of another FRDM-K64, connect the PTC17 of one FRDM-K64 to PTC16 of another FRDM-K64.
Pls following the sequence:
1)enable PORTC gated clock
2)assign PTC16/PTC17 as UART3 pins.
3)call the SDK function to transfer data.
BTW, pls test the UART3_Tx pin via scope to check if there is UART signal when you transfer data in a forever loop.
Hope it can help you
BR
Xiangjun Rong
Thanks for your response
I think I have done as you've said. Though I still need to test the pin via scope though.
for one I have
CLOCK_EnableClock(kCLOCK_PortC);
for two I have
PORT_SetPinMux(PORTC, 16u, kPORT_MuxAlt3);
PORT_SetPinMux(PORTC, 17u, kPORT_MuxAlt3);
for three I'm using the UART_WriteBlocking and UART_ReadBlocking functions. Do you know if these functions continue to transmit until they are received? Or should I try to use the nonblocking forms of these functions?
Thanks,
Timothy
Hi, Timothy,
You have to connect the GND together for the two board.
BR
Xiangjun Rong
Hi, Timothy,
For UART, the transmitting and receiving process are independent.
BR
Xiangjun rong
void UART_WriteBlocking(UART_Type *base, const uint8_t *data, size_t length)
{
/* This API can only ensure that the data is written into the data buffer but can't
ensure all data in the data buffer are sent into the transmit shift buffer. */
while (length--)
{
while (!(base->S1 & UART_S1_TDRE_MASK))
{
}
base->D = *(data++);
}
}