Are you compiling with -O1 or similar? I believe that some level of optimization must be specified at compile time in order for _delay_ms() to operate correctly. See http://www.nongnu.org/avr-libc/user-manual/group__util__delay.html
-John On Sun, Dec 1, 2013 at 11:41 AM, dfx <d...@dfx.it> wrote: > I made a very simple circuit for LED to blink. > > The code is as follows: > > # include <avr/io.h> > # define F_CPU 20000000UL > # include <util/delay.h> > > int main (void) { > DDRB | = _BV (DDB0); > while (1) { > PORTB ^ = _BV (PB0); > _delay_ms (10000); > } > } > > The processor is an ATMEGA324PA with clock = 20 MHz. > The fuses are: > > lfuse = 0x4F > hfuse = 0x99 > eFUSE = 0xFF. > > The problem is that the period of switching on / off of the LED is > approximately 16 seconds. instead of 20 seconds expected. > > Where is the error? What should I check for a period of 20 seconds? > > Thank you to those who can help me. > > Domenico > > PS: I suppose that with a quartz 16 MHz operation would be correct, but > there is a way to use one 20 Mhz? > > > > --- > Questa e-mail è priva di virus e malware perché è attiva la protezione > avast! Antivirus. > http://www.avast.com > > _______________________________________________ > AVR-GCC-list mailing list > AVR-GCC-list@nongnu.org > https://lists.nongnu.org/mailman/listinfo/avr-gcc-list > >
_______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list