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).