Programming standalone ATmega328p-pu, works but runs slow

Hello,

I recently bought parts to build a breadboard arduino; I bought the ATmega328 from Mouser, this one: http://mouser.com/Search/Refine.aspx?Keyword=556-ATMEGA328P-PU

To verify my breadboard setup I took my existing Uno chip off the Uno board and put it onto the breadboard; I had the blink program already on it and it ran the led on the breadboard properly, every 1 second.

To program my Mouser chip I've tried a couple different approaches, using either my existing Uno board as the programmer, and also using avrdude at the commandline to load the hex file.

In both cases I used the Blink sketch as my sample program for the target chip. When I install the chip onto my breadboard it runs the Blink program on it, however its running really slow ... about 16 seconds to blink off, then 16 seconds to blink on, repeats every 16 seconds.

The wiring for programming the chip seem pretty consistent across the various tutorials; I used this wiring example, including the crystal. http://pdp11.byethost12.com/AVR/ArduinoAsProgrammer.htm

Any ideas as to why the blink program might be running so slow?

Thanks,
Eric

From the factory, the ATmega328P comes with the system clock set to use the internal 8MHz RC oscillator divided by 8, in other words, the system clock is 1MHz, which as you observed, is 1/16 as fast as the Uno 16MHz clock.

Either do "burn bootloader" from the IDE, or use AVRDUDE to set the fuse bytes to use the external crystal rather than the internal oscillator.

1 Like

Any ideas as to why the blink program might be running so slow?

The most likely cause is incorrect fuse setting in the chip. Even though you have a 16 Mhz crystal wired to the chip, it ships as default with the fuse settings for using it's internal 8 Mhz clock and a /8 prescaler, so it's effective speed is 1 Mhz. Verify and correct fuse settings should get you going.

Lefty

ah, thanks guys. :slight_smile:

Used avrdude and added the high and low fuse values on the command line and now the blink runs at normal 1 second interval.

Cheers!

Eric

Excellent!