[Top][All Lists]

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

Re: [avr-gcc-list] Blink period shorter than expected

From: John Gallagher
Subject: Re: [avr-gcc-list] Blink period shorter than expected
Date: Sun, 1 Dec 2013 14:44:46 -0500

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


On Sun, Dec 1, 2013 at 11:41 AM, dfx <address@hidden> 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.


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.

AVR-GCC-list mailing list

reply via email to

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