[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Global variables and ISRs ???

From: Lars Noschinski
Subject: Re: [avr-gcc-list] Global variables and ISRs ???
Date: Tue, 6 Sep 2005 21:48:50 +0200
User-agent: mutt-ng devel (Linux)

* Vincent Trouilliez <address@hidden> [2005-09-06 21:37]:
Problem : on my ATmega32, after several experiments (only just started
using it, learning...), I am suffering a big problem. It seems that when
I declare a variable as global, then modify it within an interrupt
routine, the 'main' function can't see that the variable has been
modified, as if it weren't a global variable... hmmm.

You must declare the global variable as volatile (or as register), if
you want to modify in an ISR.

So replace

   unsigned char flag, bin;  //global variables


   volatile unsigned char flag, bin;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]