View Single Post
  #5   Spotlight this post!  
Unread 10-01-2005, 09:07
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,759
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: White Paper Discuss: Interrupts for Dummies

Quote:
Originally Posted by prograid
Do you need to disable the interrupts if you want to access the variables changed by the interrupt service routine or is disabling only necessary when the variables are changed?
Thanks
If it's a one shot use like x = encoder count;
You don't have to disable the interrupts.

Caution: If you need to reference the variable several times like:
if (encoder count == 10)
x += encoder count
The value of encoder count the second time won't necessarily be the same as the first reference. Make it a habit to move any interrupt variable to a working variable if you plan on using it repeatedly (in a calculation too).
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote