ATMega328P 8MHz internal clock running fast

Hi

I have programmed an ATMega328P running on 8MHz internal clock using Carlos Rodrigues's ATMega chips (no bootloader) board manager add on.

The program runs but is running at twice the speed, if there was a speed issue I would have expected it to run at half the speed!!!!

Any ideas as to why this might be?

Thanks

Richard

My crystal ball says that the problem is on line 42 of the code that you didn't show us for measuring the speed.

Simple program to flash led once every second but flashes twice a second.

int LED = 4;

void setup() {
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
}

void loop() {
digitalWrite(LED, HIGH);
delay(100);
digitalWrite(LED, LOW);
delay(900);
}

Did you do "burn bootloader" to set the fuses to tell it to run at 8mhz, or do you still have it connected to a 16mhz crystal and running at that speed?

What is the hardware setup? Is there an external 16 MHz clock source?

I didn't burn a bootloader, I burnt the sketch direct using a USBTiny ISP.

There is a 16MHz crystal connected but I figured that wouldn't matter as the fuses should set it so those pins aren't connected internally to the clocking.

RichardS72:
I didn't burn a bootloader, I burnt the sketch direct using a USBTiny ISP.

There is a 16MHz crystal connected but I figured that wouldn't matter as the fuses should set it so those pins aren't connected internally to the clocking.

Uploading the sketch does not set the fuses, even via ISP.

Use burn bootloader to set the fuses - even if you're not using a bootloader (and even on boards that don't have a bootloader), you still need to do "burn bootloader" to set the fuses.

Thanks, that worked. :slight_smile: :slight_smile: :slight_smile: