KSDK + MQX + UART recommended way?

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

KSDK + MQX + UART recommended way?

Jump to solution
1,085 Views
rajbatra
Contributor IV

I've spent the day trying to figure out the best way to implement UART code on my KDS leveraging MQX on my K64F and am more confused than ever.

 

Should I be using the NIO drivers which according to this link: Is there a document detailing the use of the KSDK “I/O subsystem (NIO)” device drivers?  are not documented for KSDK (and comment made to abandon the KSDK approach) or should I use the fsl_uart_driver methods as provided in the KSDK examples folder? There's been discussion that the uart drivers in KSDK isn't so smooth with MQX (UART Rx (callback) Makes MQX Weird))

 

Appreciate any advice on the matter,

-Raj

Labels (1)
1 Solution
483 Views
rajbatra
Contributor IV

I think I found the issue as my stress testing for over an hour has not produced one MQX_UNHANDLED_INTERRUPT error.

Notice above that I had named my interrupt handler UART4_RX_TX_IRQHandler, well reading more carefully the app note from Jorge Gonzalez 'Interrupt_handling_KSDK.pdf' it states:

1- Due to the MQX RTOS interrupt handling mechanism, the names of the ISR entry functions must be different than those in the CMSIS startup code file (startup_<device>.S), otherwise the kernel ISR is not called when the corresponding interrupt triggers.

2- A valid approach is to copy the corresponding fsl_<peripheral>_irq.cfile to the application and renaming the ISR entry functions by adding “MQX” at the beginning (e.g. MQX_I2C0_IRQHandler).

So, I renamed the handler to MQX_UART4_RX_TX_IRQHandler and things seem to be OK.

I'll mark this as correct unless I find something different.

View solution in original post

0 Kudos
4 Replies
483 Views
rajbatra
Contributor IV

Quick update -

Today, I tried using the fsl_uart_drivers (UART_DRV_SendData/ReceiveData (both blocking and non-blocking)). It would run for a very short time, and then I would see that the task utilizing the uart would go into the MQX_UNHANDLED_INTERRUPT (0x41) state.

It maybe a bug on my side but not sure. If anyone has successfully used the UART_DRV_SendData/ReceiveData with MQX/KSDK or could point me to an example that would help.

I will now try the NIO driver and see if it gives me better results.

0 Kudos
483 Views
rajbatra
Contributor IV

I did get the fsl_uart_drivers to work.  I didn't have a cpu.c as the MQX Acting weird article suggested. However, when I initialize by UART, I added the following line:

NVIC_SetPriority(UART4_RX_TX_IRQn, 2);

(there was debate whether it should be 2 or 0x80), but after putting that in place things worked as expected.

483 Views
rajbatra
Contributor IV

After a day of stress testing, I found that MQX crashes intermittently where the task handling the UART goes into MQX_UNHANDLED_INTERRUPT state.

My uartInitialize() method which I can during the _create_task() is as follows:

Error uartInitialize(void)

{

    NVIC_SetPriority(UART4_RX_TX_IRQn, 1);

    //OSA_InstallIntHandler(UART4_RX_TX_IRQn, UART4_RX_TX_IRQHandler); (Wasn't sure if this was necessary - didn't help!)

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

    if (kStatus_UART_Success !=

            UART_DRV_Init(UART4_IDX, &uartState, &uartConfig))

    {

        SEGGER_RTT_printf(0, "UART Failed to initialize! Exiting.\r\n");

        return(ERROR);

    }

    SEGGER_RTT_printf(0, "UART initialized.\r\n");

    return(NO_ERROR);

}

As I'm new to KSDK and MQX, this has been challenging. Does anyone have a working example of talking to UART4 with KSDK and MQX that they can share?

0 Kudos
484 Views
rajbatra
Contributor IV

I think I found the issue as my stress testing for over an hour has not produced one MQX_UNHANDLED_INTERRUPT error.

Notice above that I had named my interrupt handler UART4_RX_TX_IRQHandler, well reading more carefully the app note from Jorge Gonzalez 'Interrupt_handling_KSDK.pdf' it states:

1- Due to the MQX RTOS interrupt handling mechanism, the names of the ISR entry functions must be different than those in the CMSIS startup code file (startup_<device>.S), otherwise the kernel ISR is not called when the corresponding interrupt triggers.

2- A valid approach is to copy the corresponding fsl_<peripheral>_irq.cfile to the application and renaming the ISR entry functions by adding “MQX” at the beginning (e.g. MQX_I2C0_IRQHandler).

So, I renamed the handler to MQX_UART4_RX_TX_IRQHandler and things seem to be OK.

I'll mark this as correct unless I find something different.

0 Kudos