Task freezes but the status is eReady (xmega AVR + freeRTOS)

Good day everyone. I have an issue that have been bugging me for about three days now. After I put the microcontroller to sleep (power save) and wake it up again, sometimes (like 10% of the time) one of the tasks freezes at a random line of code so it looks like its an issue with freeRTOS. The status of the task remains eReady but it just won’t execute anymore. Is this even possible or should I look for problem somewhere else? Any idea on what could give me the clue about whats happening (aside from the eReady status)? AVR: Xmega256A3U Thank you! …and sorry for not providing any code but it’s literally thousands of lines.

Task freezes but the status is eReady (xmega AVR + freeRTOS)

How are you putting the processor to sleep? Does the clock keep running? What happens to ‘time’ when asleep? Does the tick wake the system up from sleep? Do the CPU registers and RAM retain their values while asleep?

Task freezes but the status is eReady (xmega AVR + freeRTOS)

I put it to sleep by setting the mode to power-save, setting the sleep enable register and running sleep_cpu (from avr/sleep.h) in a while loop. The condition in while is a (hi/low) status of a certain input pin. I have tried to suspend all task with vTaskSuspendAll() and resuming them after waking the processor from sleep but it had no effect on the malfunctioning task. The CPU registers and RAM retain their content. The task never failed to launch if I just reset the processor (erasing all the volatile memory in process). The strangest thing is the inconsistency of the result. I can put the processor to sleep for an exact ammount of seconds, observe the outcome, reset the whole setup and do the exact same thing again and sometimes (most of the time, like 90%) it works, but sometimes it freezes on the most random places in the code.

Task freezes but the status is eReady (xmega AVR + freeRTOS)

reply below

Task freezes but the status is eReady (xmega AVR + freeRTOS)

I put it to sleep by setting the mode to power-save, setting the sleep enable register and running sleep_cpu (from avr/sleep.h) in a while loop
Without digging through the data sheets I wouldn’t know what the effect of that was.
The CPU registers and RAM retain their content.
Ok, good. What about the clock clock that generates the tick interrupt? Does that stop in sleep mode? The reason for asking is that if the processor is in sleep mode past a tick interrupt (it stays sleeping for one or more tick interrupts) then you need to adjust the tick count when you come out of sleep mode. Otherwise a task that would wake up in 100 ticks if the processor didn’t go to sleep, would wake up 100 ticks after the processor came out of sleep mode – even if the processor was in sleep mode for 99 tick periods. The tickless low power examples use the vTaskStepTick() function for that purpose.