Passing Variables into ISR's

Hey Guys,

I’m using AVR-GCC.

I have a global variable that is the address i want my data to be stored into.

how do i pass it into my ISR? do i have to use pointers?

Matt

if its global it should be available in the ISR

a global variable, say, in C, is declared outside any function, in file A, and declared extern in all other files.

Be sure to declare it as “volatile” so the compiler won’t cache it in a register.

And if the variable is larger than the atomic size of the microprocessor, disable interrupts while altering the variable. Of course, in the ISR, you don’t need to disable interrupts.

You want to disable interrupts during any multi-byte number operations that can be interrupted. I had this happen to me once and couldn’t figure out why some of the numbers that I was expecting in a certain range were getting “corrupted”.