[Top][All Lists]

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

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

From: Adrian Cottle
Subject: RE: [avr-gcc-list] for loop problem
Date: Fri, 17 Jan 2003 12:34:21 -0000

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;


this still needs the delay in to work

any idea?




> 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.

Kursiv, fett, bunt,... WEB.DE FreeMail kann alles - mit der HTML-Mail

This e-mail has been scanned for all viruses by Star Internet. The service 
is powered by MessageLabs. For more information on a proactive anti-virus 
service working around the clock, around the globe, visit:


This message is confidential and intended solely for the use of the 
individual or entity to whom it is addressed. If you are not the intended 
recipient, please contact us, delete the message from your computer and destroy 
any copies. Any review, distribution, copying, other use of, or the taking of 
any action in reliance upon its contents without our prior permission is 
Internet communications are not always secure and therefore Horstmann 
Controls Limited does not accept legal responsibility for this message. 
 The recipient is responsible for verifying its authenticity before acting on 
the contents.  Any attachment may contain software viruses, we cannot accept 
liability for any damage which you sustain as a result of software viruses.  
You should carry out your own virus checks before opening any attachment.  Any 
views or opinions presented are solely those of the author and do not 
necessarily represent those of Horstmann Controls Limited.
Horstmann Controls Limited
South Bristol Business Park
Roman Farm Road
Bristol, BS4 1UP
Tel     :       +44 (0) 117 978 8700
Fax     :       +44 (0) 117 978 8701
Web     :       www.horstmann.co.uk
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. 

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

reply via email to

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