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

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

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


From: Volkmar Dierkes
Subject: Re: RE: [avr-gcc-list] for loop problem
Date: Fri, 17 Jan 2003 13:54:59 +0100

Adrian,

what is the exact problem? Does it hang in the loop (I can't imagine) or does 
gcc optimize the loop to nothing (deleted it)? In the last case it might be 
neccessary to include a
asm("nop");
(instead of your msdelay(1)) in the loop. With this it shouldn't delete it. 
Maybe there are other/better ways, but I think this should help. And even 
sometimes it helps if you look at the generated code what the compiler creates. 
Which optimization level do you using?

Volkmar

"address@hidden" <address@hidden> schrieb am 17.01.03 13:40:33:
> 
> 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?
> 
> thanks
> 
> adrian
> 
> 
> 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
> 
> 
> 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:
> 
> http://www.star.net.uk
> 
> 
> 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 prohibited.
> 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. 
> 


______________________________________________________________________________
Mit der Gruppen-SMS von WEB.DE FreeMail erreichen Sie mit einem Klick 
alle Freunde gleichzeitig! http://freemail.web.de/features/?mc=021180

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



reply via email to

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