I’m using FreeRTOS 8.0.1 on an MSP430 F5335 (the IAR MSP430X port). I’m attempting to use tickless idle mode but am having a problem with FreeRTOS timers.
My application spends most of its time asleep. Every 15 seconds it wakes up, stays awake for about 200ms, and then goes back to sleep. During the wake period, I want to use a couple of timers.
So, I have three timers - one with a period of 15s and another two with shorter periods. The 15s timer runs always. The other two get started by the 15s timer callback. They get stopped by the callback of one of them once a particular condition is met.
What I see happen is that the system starts up correctly. It then correctly goes to sleep as FreeRTOS calls vPortSuppressTicksAndSleep() with a parameter corresponding to just less then 15s. I wake up, do my stuff, and then stop the two other timers. But I never get called to go back to sleep again.
I’ve spent a bit of time debugging this and it looks like there’s some kind of race in the timer handling code. It looks like prvGetExpectedIdleTime() always return 1.
I’m sure that the other two timers are stopped. Also, the period of my other timers are greater than one tick, so I don’t think that’s the problem.
In the mean time, I’ve worked around it by setting the period of the two other times to > 15s. That seems to work but is pretty ugly. It also shows that my sleep/wake stuff is working correctly.
I’ll spend more time coming up with a program that demonstrates it. But before I do, I’d like to check whether anybody else has seen this before.