Problems integrating lpuart example code with FreeRTOS

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

Problems integrating lpuart example code with FreeRTOS

681 Views
billr
Contributor I

I'm using the S32K148 AVB with S32DS 3.4 and FreeRTOS. Starting with the bundle freertos demo, I'm able to build, load to the EVB and run the blinking LED. Now, I'm trying to add lpuart support to get console input and output. I've added the lpuart1 component and configured the pins to use PC6 and PC7. In rtos.c, I added the rxCallback() function direct from the lpuart example main.c code. In prvSetupHardware(), I added:

   LPUART_DRV_Init(INST_LPUART_LPUART_1, &lpUartState1, &lpUartInitConfig1);
   LPUART_DRV_InstallRxCallback(INST_LPUART_LPUART_1, rxCallback, NULL);

In rtos_start(), after the prvSetupHardware() call, I added:

    LPUART_DRV_SendDataBlocking(INST_LPUART_LPUART_1, (uint8_t *)welcomeMsg, strlen(welcomeMsg), TIMEOUT);

When I run it, it faults out with a bus fault error. Specifically, it says:

  Number of threads 1 (Scheduler not yet running)
  BusFault: An imprecise (asynchronous) data access error has occurred.
  HardFault: A fault has been escalated to a hard fault.

with the debugger stopped at DefaultISR.

I have stepped into that function, all the way down to OSIF_SemaWait() in osif_freertos.c, which eventually calls xTaskCheckForTimeOut() which executes this block of code:

#if ( INCLUDE_xTaskAbortDelay == 1 )
    if( pxCurrentTCB->ucDelayAborted != ( uint8_t ) pdFALSE )
    {
        /* The delay was aborted, which is not the same as a time out,
         * but has the same result. */
        pxCurrentTCB->ucDelayAborted = pdFALSE;
        xReturn = pdTRUE;    <<<<--------
}
else
#endif

As soon as the arrowed line is executed the abort occurs.

Does anyone have any clues what might be going on?  I've spent many hours on this and am stuck.

0 Kudos
3 Replies

647 Views
billr
Contributor I

So I tried moving the serial port config into the beginning of prvQueueReceiveTask() of the freertos demo, which will get called after the scheduler runs. This is better, in that the app doesn't abort anymore, but now it's stuck in LPUART_DRV_SendDataBlocking(), specifically into the OSWait call, it seems, with nothing coming out on the console. I'm doing the exact same UART initialization as in the lpuart example (which does work). Is there extra work in FreeRTOS I need to do to enable the interrupts, as that's kind of what it looks like from an outside view?

 

Edit: I changed the call to LPUART_DRV_SendDataPolling() and it didn't hang and returned 0, so it does appear there's an interrupt issue of some sort. At least I can move forward now by using the polling version until I can figure out why the interrupts are not enabled.

0 Kudos

664 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi Bill,

if a module uses OS services (like mentioned OSIF), it is mandatory to call its init function after starting the scheduler.

I can remember this discussion, you can take a look:

https://www.freertos.org/FreeRTOS_Support_Forum_Archive/March_2017/freertos_What_is_normal_method_fo...

Regards,

Lukas

0 Kudos

658 Views
billr
Contributor I

Thanks, Lukas! I'll give that a try and see if it solves my problems.

0 Kudos