nobo...@web.de wrote:
yes, you should use something like a mutex but if you modify a global
variable in a ISR that variable must be volatile. Most commercial

it's not a "must" in many cases. on function entry, all variables are loaded from RAM anyway (except for functions that are inlined). so, if you don't need to detect changes on the varaible within a loop, you can often get away without volatile. but as Rolf points out, declaring a variable as volatile (that is used from ints and main) is a good idea and you're on the safe side.

compilers like the ones from IAR do handle every variable as volatile but gcc does not. ANSI allows both versions.
Without volatile the code is less portable.

Rolf


Reply via email to