Log in

View Full Version : Timers causing code errors?


Uberbots
20-01-2008, 22:57
Hey, i implemented a simple timer that dings every 25ms, for the purposes of differentiating an encoder signal. Before i implemented it, the code was working fine, but after i did i get code errors (red light of doom) that seem to be resolved by a simple press of the reset button... and then it doesnt return until i shut the robot down completely.

any suggestions/thoughts?

yes, i have downloaded master code v15 (i think its 15) to the robot and master controller.

Kevin Sevcik
20-01-2008, 23:39
Are you using a hardware timer? If so, which timer? Timer 0 is used by the Generate_PWMs() function in the standard IFI librarys. Trying to use it for your timer will play heck with things for certain.

If not, have you implemented your interrupt routine correctly? Are you not clearing the interrupts flag? Are you staying in the interrupt routine too long? Are you possibly corrupting some of your memory with your interrupt routine?

Uberbots
21-01-2008, 04:34
im pretty sure im using timer 1, and im also certain that im not corrupting memory or taking too much time... i think.

Kevin Watson
21-01-2008, 12:17
im pretty sure im using timer 1, and im also certain that im not corrupting memory or taking too much time... i think.My vote would be that you're not clearing the interrupt flag in the ISR.

-Kevin

dcbrown
21-01-2008, 19:40
Check and make sure "#pragma ... save=" is saving all of the required registers. Which ones are dependent upon your interrupt service routine code and what is used.


Posting the #pragma and the ISR code pertaining to the timer would help.

Tim Skloss
21-01-2008, 19:59
We implemented the interrupt-based timer described in the IFI white paper (http://www.ifirobotics.com/docs/timers_white_paper_2004-jan-14.pdf).

It has worked fine for us without errors.

Uberbots
22-01-2008, 02:10
ok, ill post it next time i get my hands on the code (tomorrow probably)

and i think i am clearing the flag... the error only occurs when we do a hard reset of the robot, and a soft reset fixes it.