anders8 wrote on Friday, November 20, 2009:
#Introduction:
Hi everyone, first post here. My name is Anders, embedded systems are no stranger to me, and I’m not looking for basic C help or a way to run this RTOS at 50,000 ticks a second. *grin*
#Setup
I ported FreeRTOS 6.0.0 to the Atmel AVR 1281. For those not familiar, it’s a fairly orthogonal architecture, and this model has 8k ram and uses 16 bit timers. I’ve set the tick (both the OS macros and actual hardware timers) to 1kHz. The interrupt rate was verified via some pin toggling within the OS isr and a pleasantly accurate waveform verified both the correct speed and that the RTOS was actually running. I created two test tasks, at two and five tick intervals, to toggle pins, and those motored right along, again verified with the scope.
#Problem
Naturally, the actual program is larger (about 32kB of flash out of 128kB, and maybe 4kB of ram) and now I’m getting funky activity. The OS interrupt continues to run at it’s 1kHz rate. However, a task that I’ve set to delay (not delay-until) for 50ms (so, 50 ticks in this configuration) runs correctly for the first couple seconds. It then changes and **runs continuously**.
It’s the only task running. (Apart from the idle task that I’m assuming the OS has handled properly. I haven’t put any hooks in there to test it.) So we’re talking about this task switching to running every at 200Hz to running at **19.8kHz!!** Yes, **faster than the OS tick!**
The first followup question you should ask will be “Well, what is the task doing?” by which you actually mean “What foolish business is this guy up to that’s eating up the stack and obviously overwriting some variables?” Unfortunately, no, I’m not doing recursive fractal calculations or anything like that. I’ve turned off all activity that would use stack (beyond the natural getting to the function) and really just toggling a pin.
So, for clarity, neither the OS or the overall software *crashes*, things keep running, but the scheduler gets all wacky-do.
#Conclusion
My thought is that it is not being removed from a ready list, or that the tick counter itself is having issues. (With counting/overflow, not the actual running, the scope tells me it’s still running.) What variables or lists might cause this sort of behavior, this instantly returning to being called? Any ideas?