I've got a funny question that I'm wondering if there are some general 'gotchas' etc to look into, before posting lots of detail about in the problem.
In essence, I've got an application split across ~15 source files with everything driven by a co-operative scheduler, and the scheduler itself 'ticks' on the overflow interrupt of a hardware timer. The 'tick' ISR then counts in software to split into different task frequencies and set task flags. The scheduler dispatches these in main by checking for set task flags.
My application is behaving as designed across the 50 or so tasks that it is performing, bar one little niggle at the moment. I'm reading 8 different sensors, most of which have their engineering values calculated by simple linear formulae, one however requires a lookup table due to non-linearity.
The nested set of functions that deal with this sensor in effect; reads the raw ADC value, compares it to the lookup to determine which set of values it is between, and then interpolate its before store. The issue I'm having is my interpolate function returns the wrong value... BUT - only when run in the full application, if I strip the code segments out and run them in isolation, it calculates exactly the right value as I'd expect, and the formulae themselves calculate the correct value. I originally had to deal with integer overflows that was causing this problem, even when run in isolation, but those are resolved.
So, before I pull out all the various bits of code and post it up here, a general question:
- what are the typical 'gotchas' to look for in co-operative type scheduling that could cause execution to behave differently to running it in isolation?
- I thought that given this one function is the only function that takes longer to execute than my timer overflow, that it might be due to the ISR interrupting the task (though no shared variables), so I wrapped the task in cli(); & sei(); to no avail.
- equally, if the above is literally of no help at all without code, shout and i'll throw it up!
Thanks as always