Hi, I have a strange problem with FreeRTOS xTimers not waking up, that I so far have tracked down to be related to PPI driven SAADC combined with FreeRTOS Tickless Idle.
The problem occurs if the sampling period of the adc is faster than any periodic xTimer or thread wakeup (xExpectedIdleTime). This happens both with the SoftDevice present or not, but I have chosen to debug the problem without the Softdevice to make it easier. (The SAADC is set up exactly like the example)
When I pause the program it is in the vPortSuppressTicksAndSleep function waiting in the do while(0 == (NVIC->ISPR[0] | NVIC->ISPR[1])) loop. I can step out of the breakpoint and it then continues, and I can see my LED toggle one time (controlled by an xTimer), then it stops again. When in the loop with ADC is enabled NVIC_ISPR0 is 0x0000081 and NVIC_ISPR1 is 0x00000000. Whitout ADC NVIC_ISPR0 is 0x0000001.
There are 3 ways to get around the problem. Disable tickless idle, disable the ADC (it is suficcent to remove nrf_drv_saadc_buffer_convert from the ISR) or configure any timer or thread to wake up with a period faster than the adc-timer.
My first thought was that the ADC ISR consumed too much time so I reduced it to sample once every 500ms, but still if no timer or thread is configured to wake up with a period faster than 500ms it is stuck again.
The priority of the TmrSvc is 2 (lower than the ADC interrupt which is 6). I have tried all kinds of combinations regarding the interrupt priority, but the TmrSvc is always blocked and IdleTask is Running (stuck in the loop) while the ADC interrupt is occuring with the expected period. My thought now is that maybe the ADC interrupt is "stealing" the wake up, not correctly setting the next time to wake up the timers or something..
I can get around this by having a timer just waking up now and then doing nothing, or trigger the ADC manually, but I really want to understand why this is happening, and how I can fix it. Any thoughts would be appreciated.
I am running SDK 11 on NRF52832 at PC10040. Compiling with IAR 7.50.3