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: Volkmar Dierkes
Subject: Re: [avr-gcc-list] for loop problem
Date: Fri, 17 Jan 2003 13:13:39 +0100

Adrian,

> I have the function below (well part of it) and it waits in a loop until 
> the UART flag is flagged.  If i put a 100ms delay in or do something like 
> send a byte to the uart it works fine, but as soon as i leave a empty for 
> loop it crashed and needs resettting.
...
> int Pulse_Handler(void)
> {
> int i;
> uart_send_byte(33);
>   while(UART_Flag == 0)
>   {
>       msdelay(1);
>  //uart_send_byte(46);
>   }
>   UART_Flag = 0 ;                             
>   uart_send_byte(85);  

You need to define UART_Flag as volatile. If you look at the generated code you 
can see that without volatile it checks only once for UART_Flag and runs than 
into an endless loop. With the volatile you can see that the compare is 
included into the loop.

Volkmar
______________________________________________________________________________
Kursiv, fett, bunt,... WEB.DE FreeMail kann alles - mit der HTML-Mail
http://freemail.web.de/features/?mc=021143

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



reply via email to

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