[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Global variables and ISRs ???
From: |
Johnathan Corgan |
Subject: |
Re: [avr-gcc-list] Global variables and ISRs ??? |
Date: |
Tue, 06 Sep 2005 12:58:40 -0700 |
User-agent: |
Mozilla Thunderbird 1.0.6 (X11/20050727) |
Vincent Trouilliez wrote:
> unsigned char flag, bin; //global variables
Try making 'flag' volatile:
volatile unsigned char flag;
unsigned char bin;
What's probably happening is the compiler, not seeing that 'flag' is
modified anywhere in the while loop, isn't reloading it every loop
iteration (this is a common optimization.) By declaring 'flag' as
volatile, you tell the compiler that it's value might change at any
time, unrelated to the code that is currently executing (in this case,
by your ISR.) Now the compiler will reload the value from SRAM every
time it's needed.
You can check your assembly output to see if the SRAM location for flag
is getting accessed from within the loop to verify this is the problem.
-Johnathan
signature.asc
Description: OpenPGP digital signature
- [avr-gcc-list] Global variables and ISRs ???, Vincent Trouilliez, 2005/09/06
- Re: [avr-gcc-list] Global variables and ISRs ???, Lars Noschinski, 2005/09/06
- Re: [avr-gcc-list] Global variables and ISRs ???, Lars Noschinski, 2005/09/14
- Re: [avr-gcc-list] Global variables and ISRs ???, Rich Neswold, 2005/09/14
- Re: [avr-gcc-list] Global variables and ISRs ???, David Brown, 2005/09/15
- Re: [avr-gcc-list] Global variables and ISRs ???, Keith Gudger, 2005/09/15
- Re: [avr-gcc-list] Global variables and ISRs ???, Chip Webb, 2005/09/15
- Re: [avr-gcc-list] Global variables and ISRs ???, Joerg Wunsch, 2005/09/15
Re: [avr-gcc-list] Global variables and ISRs ???, Christopher X. Candreva, 2005/09/06
Re: [avr-gcc-list] Global variables and ISRs ???,
Johnathan Corgan <=
Re: [avr-gcc-list] Global variables and ISRs ???, Parthasaradhi Nayani, 2005/09/06
- Re: [avr-gcc-list] Global variables and ISRs ???, David Brown, 2005/09/07
- Re: [avr-gcc-list] Global variables and ISRs ???, Vincent Trouilliez, 2005/09/07
- Re: [avr-gcc-list] Global variables and ISRs ???, Lars Noschinski, 2005/09/07
- Re: [avr-gcc-list] Global variables and ISRs ???, Vincent Trouilliez, 2005/09/07
- Re: [avr-gcc-list] Global variables and ISRs ???, David Brown, 2005/09/07
- Re: [avr-gcc-list] DIV instruction (WAS: Global variables and ISRs ???), Vincent Trouilliez, 2005/09/07
- Re: [avr-gcc-list] Global variables and ISRs ???, Alex Wenger, 2005/09/07
- Re: [avr-gcc-list] Global variables and ISRs ???, Vincent Trouilliez, 2005/09/07