Weird time behavior (millis, delay and tune) when the processor runs outside the Arduino board

I'm currently building two guitar effect pedals. They use analog circuitry using the Arduino as the brain to interact with the circuit via PWM pins or digital resistors. I have breadboarded both of them with an Arduino Nano each and they work flawlessly. However, a Nano is too bulky and expensive to put it within the PCB and it comes with legal restrictions, so my goal was always to just put a single Atmega328P in the PCB after developing on the breadboards with the Nanos for convenience.

I ordered PCBs, soldered everything and anything regarding time doesn't work as expected.

  • I send sound with the tone function for calibration and it just makes a ton of noise instead of hitting a 880Hz A note
  • millis and delays seem to work way slower and take longer, so the tap tempos I implemented are not working.

It's like time in the standalone Atmegas passed way slower than in the Nanos. Just to test it, I created a simple blinking sketch with delays and a simple 1000 delay takes 16s @#$%& seconds!!! I'd say the crystals are good, but I'm starting to go nuts with this.

Any ideas of what I've done wrong???! Here's the working breadboards along with the PCBs with crazy timing:
IMG_20210917_122926|666x500
IMG_20210917_122937|666x500

How are you programming the atmega328P? A bare chip comes with the clock source set to the internal oscillator at 1MHz, you will need to set the fuses properly to change to an external 16MHz crystal. If you are using the Arduino IDE, you can use Tools > Burn Bootloader to set the fuses even if you do not use a bootloader, just need a board package that has the option of no bootloader such as MCUdude's MiniCore.

That would explain the time difference!!! I'll do it right away. Thanks David!!

Hi, @guillemdc
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

Your images.


Can you please post a copy of your circuit?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Hi all.

David, they worked flawlessly after burning the bootloader. Thanks a million!!!

Tom, my apologies. I rushed too much out of frustration. I gotta read that for the next time. BTW, I can't post the circuit since I intend to sell them soon. I left my job at the telco industry to sell this devices and see if I can earn for a living. However, I can describe them for you in private in case you are interested.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.