View Single Post
  #12   Spotlight this post!  
Unread 29-10-2007, 01:49
eugenebrooks eugenebrooks is offline
Team Role: Engineer
AKA: Dr. Brooks
no team (WRRF)
 
Join Date: Jan 2004
Rookie Year: 2001
Location: Livermore, CA
Posts: 601
eugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond repute
Re: Code error causing robot to go into programming mode.

In the code example above, the PROD registers are saved/restored in a nested manner although from the discussion this was not intended.

The W,BSR, and STATUS registers are also saved/restored in a nested manner when the strategy described above is used and you might be better off writing your own version of whatever math routine that you need, with its own internal state, that does not require saving/restoring MATH_DATA if performance is an issue.

In addition to the business of saving/restoring data that the interrupt handler uses you also have to worry about race conditions when communicating multi-byte data between the interrupt handler and the main program. The individual bytes of a multi-byte value are read/written one at a time on the micro-controller and the interrupt can strike between these individual reads/writes, leading to a corrupt multi-byte value being transferred between the interrupt handlers and the main program.

So, write that interrupt code and associated accessor routines with care...

Eugene

Last edited by eugenebrooks : 29-10-2007 at 02:39.