michael_v_truong wrote:
- Right now I'm having trouble with global variables. I defined a variable in one of my headerfiles. My main program can change and manipulate that variable, but if I manipulate it in the interrupt, I can confirm that change in the interrupt, but once I return to main, the variable reverts back to its previous state (before the interrupt).

try: volatile int myglobalvar;
gcc optimizes variable usage and loads them into a register e.g. in a loop. if the variable can change from the outside, while running a function, you have to declare it as volatile.

chris

Reply via email to