What I'm trying to do is simple enough, read ASCII data from UART. I'm using an NXP kl27 and am using Kinetis 1.2.0. I have a GPS (tx pin) wired to pin PTD2, and have that pin configured to be UART2_Rx.
PORT_HAL_SetMuxMode(PORTD,2u,kPortMuxAlt3); //UART2_Rx
PORT_HAL_SetMuxMode(PORTE,22u,kPortMuxAlt4); //UART2_Tx (unused)
The configuration for the UART object is as follows:
uart_user_config_t g_uartConfig= {
.baudRate = 9600u,
.parityMode = kUartParityDisabled,
.stopBitCount = kUartOneStopBit,
.bitCountPerChar = kUart8BitsPerChar,
};
Finally, here is the code I'm using to try and recieive UART data:
uart_state_t g_uartState;
UART_DRV_Init(2u, &g_uartState, &g_uartConfig);
uint8_t rxChar
// Uart #, return data, data count, timeout in miliseconds
UART_DRV_ReceiveDataBlocking(2u, &rxChar, 1u,1000u);
The problem is UART_DRV_RecieveDataBlocking never returns.
Here is the relevant parts of the schematic if that helps:
Far as I can tell I'm following every example/demo I've seen with reading UART data. If anyone has any ideas about what is going on I'd love to hear it.
The problem was indeed software. My cmakeLists file was missing this:
"${ProjDirPath}/KSDK_1.2.0/platform/drivers/src/uart/fsl_uart_irq.c"
This file properly sets up the UART interrupts.