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

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

Re: [avr-gcc-list] Optimization?


From: Chris Baugher
Subject: Re: [avr-gcc-list] Optimization?
Date: Tue, 13 Nov 2001 16:53:18 -0600 (CST)

What is the clock speed?

I'm thinking that maybe it IS working but the delay is so long that it
never gets past the first set of delay loops.

When you compile with -O3 it may optimize out the k=k+1 and shorten the 
length of the delay to where you can actually see the blinking.

C|


On Mon, 12 Nov 2001, Patrick Lanphier wrote:

> Well the below code works fine, flashing that is, when using the -O3
> optimization but does not work with -O1 optimization, I don't understand.
> 
> 
> /**************************************************************************
> 
> avr-gcc -O0 -mmcu=at90s2313 -c demo2.c -o main.o
> avr-gcc -o main.elf main.o
> avr-objcopy -O ihex main.elf main.hex
> 
> ***************************************************************************/
> 
> #include <io.h>
> #include <interrupt.h>
> #include <sig-avr.h>
> 
> int main(void)
> {
>   uint8_t f,i, j, k;
> 
>   outp(255, DDRB);           /* port B all outputs */
>   outp(0, PORTB);          /* turn all leds off  */
> 
>   while(1){
>     outp(0, PORTB);        // turn led on
>     for(f=0; f<255; f++)      // delay
>       for(i=0; i<255; i++)
>         for(j=0; j<255; j++)
>           k=k+1;
>     outp(255, PORTB);          // turn led off
>     for(f=0; f<255; f++)        // delay
>       for(i=0; i<255; i++)
>         for(j=0; j<255; j++)
>           k=k+1;
>   }
> }
> 
> Patrick Lanphier
> The Artemis Group
> http://www.artemisgroup.com
> phone: 814-235-0444
>   fax: 800-582-9710
> 
> 
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://avr.jpk.co.nz/mailman/listinfo/avr-gcc-list
> 




reply via email to

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