Accessing global variables from interrupt

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello!

I use the latest WinAVR release (20030115) and AVRStudio 3.56 under Win98, and programming ATMega103.
My project's makefile is the sample from WinAVR with the neccessary modifications.

My problem is:
I need to change the value of a global variable from my TIMER0 interrupt routine, but when the interrupt returns, the variable remains unchanged. Should I use some specific keyword at variable declaration, or something else?

Thank You
Zoltan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Zoltan,

use "volatile" variable and see FAQ #1 in manual:

http://savannah.nongnu.org/downl...

Regards,
Martin

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you, Martin! It works fine.
I just didn't know what 'volatile' keyword means exactly.