avr-gcc-list
[Top][All Lists]
Advanced

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

AW: [avr-gcc-list] Bug in avr-libc or?


From: Oliver Schulz
Subject: AW: [avr-gcc-list] Bug in avr-libc or?
Date: Tue, 1 Jun 2004 10:29:59 +0200

Hi,

> 
> Try to declare your variable as volatile:
>  
> volatile uint8_t var;
> 
> This indicates that a variable may be changed in a way which is
> unpredictable by analysing the normal program flow (such as 
> variable which
> may be changed by an interrupt handler). 
> 
Perfectly right. The avr-gcc compiler optimizes the code for speed and
size, and it thought, that using a register for this variable might be
an good idea. Indeed it is, unless this variable is altered in an
interrupt routine or by a different thread..

The reason why it "worked" with Linux C code is, because a PC platform
(i386) has just 4 general registers (ax to dx), that normally cannot be
used for "caching" variables.

Cheers,
Oliver.


reply via email to

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