avr-libc-dev
[Top][All Lists]
Advanced

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

RE: [avr-libc-dev] FDEV_SETUP_STREAM problem on ATMega8


From: Eric Weddington
Subject: RE: [avr-libc-dev] FDEV_SETUP_STREAM problem on ATMega8
Date: Fri, 06 Jul 2007 15:42:36 -0600


> -----Original Message-----
> From:
> address@hidden
> [mailto:address@hidden
> org] On Behalf Of James Pascoe
> Sent: Monday, June 25, 2007 1:07 PM
> To: address@hidden
> Subject: [avr-libc-dev] FDEV_SETUP_STREAM problem on ATMega8
>
> Dear All,
>
> I am new to this list, so I am sorry if this post is OT.
>
>
> //General short delays
> void delay_ms(uint16_t x)
> {
>   uint8_t y, z;
>   for ( ; x > 0 ; x--){
>     for ( y = 0 ; y < 90 ; y++){
>       for ( z = 0 ; z < 6 ; z++){
>         asm volatile ("nop");
>       }
>     }
>   }
> }

No need to do this. See the avr-libc user manual for <util/delay.h>


>
> I am building my code at the command line with the following:
>
> avr-gcc -mmcu=atmega8 jsp.c -o jsp.hex
>
>
> The code builds without warning and everything seems fine.

That's odd considering your command line above cannot compile a C file
directly to a hex file. GCC compiles to object code (.o), then linked to an
ELF file (.elf), then converted to a hex file (.hex) via avr-objcopy.


> I
> have an LED
> hooked
> up to the first line of portc. When I flash jsp.hex to the
> device, I see
> my LED illuminate
> but not flash (as I would expect).

Drop your home-grown do-nothing delay loops and use the ones from avr-libc.
Take a look at the compiled output. I would bet that your delay loops have
disappeared because the compiler has optimized them away.

Eric






reply via email to

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