MQX UART Non-Blocking

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MQX UART Non-Blocking

1,298 Views
scottmorrison
Contributor I

     Hello, I am using a K60 with MQX.  I am trying to install a second UART driver, in addition to the one used for stdout.  I have set up the port using UART_DRV_Init.  The port works fine if I send data using SendDataPolling, but as soon as I call SendData, the non blocking version, the system hangs.  If I stop the debugger, the code looks like it is in the unhandled interrupt processing section.

 

Do I have to install my own handler?  Here is the initialization portion of my code, this is happening inside of a thread :

 

uart_state_t uartState;

 

uart_user_config_t uartConfig = {
    .bitCountPerChar = kUart8BitsPerChar,
    .parityMode  = kUartParityDisabled,
    .stopBitCount= kUartOneStopBit,
    .baudRate    = BOARD_DEBUG_UART_BAUD
};

 

 

 

    uint8_t buff[TX_BUFFER_SIZE],respBuf[32],txBuf[128];

    uint32_t count = 0;

 

    TASK_PARAMS_PTR task_p = (TASK_PARAMS_PTR) param;

 

  

    // Initialize the uart module with base address and config structure

 

    SIM_HAL_EnableClock( SIM , kSimClockGatePortE );

    SIM_HAL_EnableClock( SIM , kSimClockGatePortD );

    SIM_HAL_EnableClock( SIM , kSimClockGatePortA );

   

    CLOCK_SYS_EnableUartClock(5u);

 

    configure_uart_pins( UART5_IDX );

   

   // Get working uart clock

 

    UART_DRV_Init(5u , &uartState, &uartConfig);

 

uartSourceClock = CLOCK_SYS_GetUartFreq( UART5_IDX );

 

// Initialize UART baud rate, bit count, parity and stop bit

   

UART_HAL_SetBaudRate(baseAddr, uartSourceClock, BOARD_DEBUG_UART_BAUD);
UART_HAL_SetBitCountPerChar(baseAddr, kUart8BitsPerChar);
UART_HAL_SetParityMode(baseAddr, kUartParityDisabled);

 

#if FSL_FEATURE_UART_HAS_STOP_BIT_CONFIG_SUPPORT

UART_HAL_SetStopBitCount(baseAddr, kUartOneStopBit);

#endif

 

// Enable the UART transmitter and receiver
UART_HAL_EnableTransmitter(baseAddr);
UART_HAL_EnableReceiver(baseAddr);

 

 

buff[0] = 'Z';

 

UART_HAL_SendDataPolling(baseAddr, buff , 1 );

 

 

UART_HAL_SendDataPolling(baseAddr, buff, 1 );

 

while(1)
{

 

   buff[0] = 'Z';

 

   //UART_HAL_SendDataPolling(baseAddr, buff, 1 );      // This works fine
     UART_DRV_SendData( 5u , buff, 1 );                            // This crashes
     OSA_TimeDelay( 250 );

 

}

 

 

Any insights or help is appreciated.

Labels (1)
0 Kudos
1 Reply

509 Views
soledad
NXP Employee
NXP Employee

Hi Scott,

Please check the below threads:

https://community.freescale.com/thread/351168#501499

HOW TO MAKE TWO SERIAL(UART) PORT IN FRDMK64F120

UART Example with KSDK

Using KSDK for interrupt driven UART?

I hope this helps,


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos