[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Optimization?
From: |
MWP |
Subject: |
Re: [avr-gcc-list] Optimization? |
Date: |
Tue, 13 Nov 2001 22:48:46 +1100 (EST) |
I wouldnt be supprised if it has somthing to do with incr k, but then not
using it. I cant answer why it works with O3 tho... weird.
try using asm("nop") instead of incr k;
MWp
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
>