util/delay.h from arduino _delay_ms not delaying in accurate time with my hardware configuration I have configured my arduino as a flash programmer and i'm sending data to an atmega328P. It is actually working and the data is send to my atmega328. But what is strange that the _delay_ms from  from the Arduino library is not delaying in accurate seconds.

_delay_ms(1000) who should wait from 1s, is actually more 8 seconds from my atmega328P hardware point of view. 

My question is what could possibly turn the program wrong. I'm strongly assuming that this a misconfigured clock cycle from my Atmega, but this is my newbie guess,  it can be something else, that's why I'm posting my question here. Can someone can hint me what's wrong with my configuration?

Here's the sample code, a dumb toggle pin on / off:

#include &lt;util/delay.h&gt; // from arduino library

/*
*/

 DDRB |= 0b0000001;

  while (1) {
    PORTB = 0b00000001;
    _delay_ms(1000); // it should be 1 second, but on my hardware it is more ~8 seconds 

    PORTB = 0b00000000;
    _delay_ms(1000);
  }   


And my configuration is (from arduino IDE) 

Arduino Pro / pro Mini (3,3v 8 Mhz) / Atmega 328

I have tried with 

Arduino Pro / pro Mini (5v 16 Mhz) / Atmega 328 

expecting that more power will affect speed, but the result is actually the same.
At a 30000 ft. level, it's because the defined F_CPU value doesn't match your hardware. This can happen because the incorrect device is chosen in the IDE or because the device is misconfigured in boards.txt, or because the hardware is somehow different from what is expected.

Given that you are using a bare ATmega328P, assuming that you've selected the correct crystal, and that the apparent time scale is 8x, it is likely that the CKDIV8 fuse is set. This means that the chip is running at 1/8 the crystal speed. You will need to unprogram (set to 1) bit 7 of the low fuse byte in order to reset it. Use AVRdude from the command line to read the low fuse byte (-U lfuse:r:-:h), set the bit (lfuse | 0x80), and then write it back (-U lfuse:w:0xnn:m).