[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Bug report
From: |
Brian Dean |
Subject: |
Re: [avr-gcc-list] Bug report |
Date: |
Sun, 6 May 2001 23:59:53 -0400 |
User-agent: |
Mutt/1.2.5i |
On Thu, Apr 19, 2001 at 10:20:42PM +0800, Kang Tin LAI wrote:
> Source:
>
> char adc_flag = NOT_RDY; /* external, (i.e., in SRAM) */
> ...
> ...
>
> while (adc_flag == NOT_RDY); /* wait for interrupt to set to RDY */
>
>
> asm generated:
>
> lds r24,adc_flag <- value is load to R24 only once
> .L33:
> tst r24 <- dead loop tests dead value
> breq .L33 <- never quit the loop
>
> Label location .L33: should be before lds instruction?
You need to qualify adc_flag as volatile, i.e.,
volatile char adc_flag = NOT_RDY;
That is a flag to the compiler telling it that the variable may be
modified without its knowledge (such as within an interrupt handler),
and thus not to optimize the access by caching its value in a
register.
-Brian
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [avr-gcc-list] Bug report,
Brian Dean <=