Quote:
Originally Posted by dcbrown
How can the autonomous routine loop and loop and loop and never
(apparently) return and still work under MPLAB/WPILIB or EasyC?
----------------------------------------------------------------
...
Slamming the stack pointer and frame pointer managed by the C compiler back to their defaults and then changing the STKPTR index to 2 and then returning normally from the interrupt service routine will make it appear as if the Autonomous() routine just returned to main() on its own. Instead, the interrupt service routine hijacked the stack and did it for us...
Yeah, we could do the same thing between iterations through Autonomous(), but this way again we don't really care how long the code path through autonomous is, it will get yanked immediately into the Operator() code when autonomous ends.
|
ghuy'cha', that's scary! There should be a prominent label on easyC to warn about this behavior. I can imagine a couple of ways it could break a program if I didn't know to watch out for it. It certainly violates the principle of least surprise.
If I hadn't already decided that easyC wasn't for me, this alone would make me worry about what other "gotchas" were lurking behind the pretty face.