Custom board F_CPU

I've made my own Arduino board. I want to run it at 16Mhz @3.3V. Yes, I know this isn't recommended. Besides the obvious reasons, is there an advantage to running it at 8Mhz? Keep in mind, I want to use i2c/serial/interrupts/NeoPixels/sleep. Will all those functions still work at 8Mhz?

In my code, I've added F_CPU 16000000 and selected clock_prescale_set(clock_div_1).

I've programmed it using an Arduino as ISP. I've selected Arduino Pro or Pro Mini. I then selected 328P 5V 16Mhz from the Processor. The delay was twice as long when blinking an LED. If I change it to 328P 3.3V 8Mhz from Processor then it works fine.

Why is this? I expected it to be the opposite. Is my crystal not properly soldered? Is it something to do with the fuses?

Is it a 16mhz crystal? Have you set the fuses to use the crystal? Maybe they're set to use the internal 8mhz oscillator instead of the external crystal.

If the delays are the wrong speed, that means that F_CPU does not match the speed that the chip is actually running at.

If the crystal was not properly soldered, but it was set to use the crystal, the board would be non-responsive.

In my code, I've added F_CPU 16000000 and selected clock_prescale_set(clock_div_1).

Note that setting F_CPU doesn't DO anything to the chip; it just tells the compiler and user code how fast the chip is supposed to be running. For it to go 16MHz, you still need to have an external 16MHz Crystal or Oscillator, and the fuses have to be set to match whichever you have.

Ahhhh. Yes, the external crystal is 16Mhz. Probably a fuse setting. Is it possible to change fuse settings if I have an Arduino as ISP programmer?

I've programmed it using an Arduino as ISP. I've selected Arduino Pro or Pro Mini. I then selected 328P 5V 16Mhz from the Processor.

. Is it possible to change fuse settings if I have an Arduino as ISP programmer?

Yes. Given your setup, use the "burn bootloader" command, or see the boards.txt to get the correct fuse setting if you don't want to install the bootloader...

westfw:
Note that setting F_CPU doesn't DO anything to the chip; it just tells the compiler and user code how fast the chip is supposed to be running. For it to go 16MHz, you still need to have an external 16MHz Crystal or Oscillator, and the fuses have to be set to match whichever you have.

I take out a AVR328 from UNO board and connect it with an external Oscillator 8MHz, so is it enough for the board running at 8MHz?

I tend to use the timer so does it need to set F_CPU to 8MHz? Thanks

imagiro1:
I've made my own Arduino board. I want to run it at 16Mhz @3.3V. Yes, I know this isn't recommended. Besides the obvious reasons, is there an advantage to running it at 8Mhz? Keep in mind, I want to use i2c/serial/interrupts/NeoPixels/sleep. Will all those functions still work at 8Mhz?

In my code, I've added F_CPU 16000000 and selected clock_prescale_set(clock_div_1).

I've programmed it using an Arduino as ISP. I've selected Arduino Pro or Pro Mini. I then selected 328P 5V 16Mhz from the Processor. The delay was twice as long when blinking an LED. If I change it to 328P 3.3V 8Mhz from Processor then it works fine.

Why is this? I expected it to be the opposite. Is my crystal not properly soldered? Is it something to do with the fuses?

One suggestion: Setup your fuses to run the crystal as FULL SWING. For the 328p, this involves changing the lowest 4 bits of the low fuse from 0b1111 to 0b0111. That is, if your lfuse is currently 0xFF, you want to change it to 0xF7.

Running the oscillator full swing will make the processor work more reliably at lower voltages.