This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FreeRTOS with configUSE_TICKLESS_IDLE activated causes a bad behaviour in the RX of UARTE

Hi to everybody,

I am working with nrf52 and SDK11. In my project I am using freertos and an UARTE with this configuration:

  • 9600bps
  • TX/RX (no CTS; no RTS)
  • HW flow control disabled.
  • No parity.
  • DMA.

DMA TX buffer of 16 bytes.

DMA RX buffer of 16 bytes, double buffer of 8 bytes.

If the configUSE_TICKLESS_IDLE is set the UARTE reception behaves strangely. I am sending frames of 7 bytes [11 22 33 44 55 66 77] looking at my uart handler once I receive NRF_DRV_UART_EVT_RX_DONE event instead of having those 7 bytes in the first 8 bytes buffer the result I get is:

DMA RX buffer 1: 11 22 33 44 55 66 00 00

DMA RX buffer 2: 77 00 00 00 00 00 00 00

And the 'p_event->data.rxtx.bytes' has a value of 6. So it seems the 7 bytes has been received but I dont know why there are only 6 registered and the 7th is in the second part of the DMA RX buffer.

I have a gpiote related to the RX_PIN (rising edge) to control the RX timeout (suposed to end a reception after 20ms of RX_PIN inactivity). This way I can avoid waitting for a complete DMA buffer size reception.

I have verified that the 7 bytes of my test frame are reaching the nrf52 in a raw. From the gpiote event handler I am reseting the timer with "xTimerResetFromISR". And once the timer expires in the timer handler I abort the uart rx:

/* Abort the current UARTE RX */
CRITICAL_REGION_ENTER();
nrf_drv_uart_rx_abort();
CRITICAL_REGION_EXIT(); 

Actually I am using the external/freertos files from the SDK12 that are supposed to fix some bugs the SDK11 has. I have also tried to solve the issue with the recomendations written in this other thread

But with the "port_cmsis_systick.c" attached by Aryan the issue is not fixed. With this file and using the updateRTOSTick() call in the handlers that use any API call to FreeRtos I am no able to receive anything, the program gets blocked at vPortSuppressTicksAndSleep.

Does anybody know why the UARTE is behaving this way and broking the frame and only capturing part of the info?

Thanks in advance for your help.

Nota: I cant post or attach my code so I is necessary I can create a support case and share it.

Parents
  • Hi dpa,
    Are you seeing this problem only when you enable TICKLESS_IDLE? in non tickless mode your code is functioning correctly?

    For me it is little confusing of how this is related to FreeRTOS? The interrupt handlers called are not FreeRTOS related at all for UART. So any events triggering the UART interrupt must have correct bytes received in the hardware irrespective of any irregularities in FreeRTOS port. Probably there is some incompatibility with the SDK drivers and FreeRTOS interrupt handling!!?? Not sure. For me to be able to debug, i request you to upload your project so that i can see the problem and attempt to debug it.

Reply
  • Hi dpa,
    Are you seeing this problem only when you enable TICKLESS_IDLE? in non tickless mode your code is functioning correctly?

    For me it is little confusing of how this is related to FreeRTOS? The interrupt handlers called are not FreeRTOS related at all for UART. So any events triggering the UART interrupt must have correct bytes received in the hardware irrespective of any irregularities in FreeRTOS port. Probably there is some incompatibility with the SDK drivers and FreeRTOS interrupt handling!!?? Not sure. For me to be able to debug, i request you to upload your project so that i can see the problem and attempt to debug it.

Children
No Data
Related