[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] do-while problem
From: |
Peter Bosscha |
Subject: |
Re: [avr-gcc-list] do-while problem |
Date: |
Wed, 05 Jun 2002 13:10:21 +0200 |
Hurrah !
You're number 155413 that has fallen for this one. (or thereabouts)
I still think there should be a FAQ for AVRGCC somewhere because you'd
be amazed at how many times this one comes up on the list.
The trick is:
For variables which are updated in interrupt routines always use the
keyword "volatile".
In your case:
volatile unsigned char ABC;
This forces the compiler to reload the variable everytime it uses it.
Regards
Peter Bosscha
>>> Arne Lynge Madsen <address@hidden> 06/05/02 11:33AM >>>
Hi,
I just realized that there migth be a bug in the generated
assempler...
do
{
} while (ABC == 0x01 );
166: 80 91 60 00 lds r24, 0x0060
16a: 81 30 cpi r24, 0x01 ; 1
16c: f1 f3 breq .-4 ; 0x16a
ABC is updated by an interrupt routine. breq.-4 only jumps back to the
cpi statement, so the updated ABC is not taken into account. Loops
forever!
do
{
} while (somefunction() != 0);
132: 86 d1 rcall .+780 ; 0x440
134: 88 23 and r24, r24
136: e9 f7 brne .-6 ; 0x132
somefunction() returns ABC. Here brne.-6 jumps back to rcall. It
works!
I currently use these packages:
binutils-2.11.2
gcc-3.0
avr-libc-20011208
Questions:
Where is this error located? binutils, gcc or avr-libc?
Could it be corrected in later versions, if so which one?
Where to report the error?
Best regards
Arne
avr-gcc-list at http://avr1.org
avr-gcc-list at http://avr1.org
- Re: [avr-gcc-list] do-while problem, (continued)
- Re: [avr-gcc-list] do-while problem, Lee Mitchell, 2002/06/14
- Re: [avr-gcc-list] do-while problem, Alexander Popov, 2002/06/14
- Re: [avr-gcc-list] do-while problem, Jesper Hansen, 2002/06/14
- Re: [avr-gcc-list] do-while problem, Vaclav Carnogursky, 2002/06/14
- Re: [avr-gcc-list] do-while problem, George Kalovyrnas, 2002/06/14
- [avr-gcc-list] ATmega8??, Chris Baugher, 2002/06/14
- Re: [avr-gcc-list] do-while problem,
Peter Bosscha <=