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

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

RE: [avr-gcc-list] for loop problem


From: E. Weddington
Subject: RE: [avr-gcc-list] for loop problem
Date: Fri, 17 Jan 2003 08:50:49 -0700

On 17 Jan 2003 at 12:34, Adrian Cottle wrote:

> I have tryed changing the flag rto static volatile and volatile. this
> seems to have corrected the UART loop problem but not the other loop
> problem
> 
> while(Timeout_Flag != 0xFF && Element_Pulse_Flag != 0xFF)
>   {
>  int i;
>  for(i=0;i<10;i++)
>  {
>  //msdelay(1);
>  }
> 
>   }
> 
> this still needs the delay in to work
> 
> any idea?

If you're optimizing, the loop will probably disappear.

Again add volatile to your declaration of i. Also, an int is 16 bits. 
You probably don't need 16 bits for a counter that will only count up 
to 10. So declare i as:
volatile unsigned char i;

HTH
Eric
avr-gcc-list at http://avr1.org



reply via email to

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