# ATmega328P internal clock weirdness

**URL:** <https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650>\
**Category:** 3rd Party Boards\
**Created:** [December 17, 2022, 9:45pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650 "2022-12-17T21:45:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ToyotaAE86Trueno](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@ToyotaAE86Trueno](https://forum.arduino.cc/u/ToyotaAE86Trueno)\
**Post date:** [December 17, 2022, 9:46pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/1 "2022-12-17T21:46:00Z")

</div>

So i have an arduino uno with a dead 16U2 controller so it has no usb. i extracted the ATmega328P from it and burnt the corresponding [MiniCore](https://github.com/MCUdude/MiniCore) bootloader and fuses so it runs from its internal 8Mhz clock using a mega2560 as an isp (i used some timer toggle stuff to generate a 8Mhz clock for the standalone chip before the fuses were set). it works fine when powered externally with [this](https://components101.com/modules/5v-mb102-breadboard-power-supply-module) breadboard power supply. but when powered from the mega2560 the internal clock stops working and it needs the 8Mhz pulse generated by the mega to run.  
any ideas why?

---

<div class="post-metadata">

**Author:** ![DrDiettrich](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/drdiettrich/32/219048_2.png) [@DrDiettrich](https://forum.arduino.cc/u/DrDiettrich)\
**Post date:** [December 18, 2022, 4:43am UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/2 "2022-12-18T04:43:06Z")

</div>

> [@ToyotaAE86Trueno](#):
>
> but when powered from the mega2560

Most probably the Mega cannot provide enough current for another controller. Show your circuit diagram including power supply.

---

<div class="post-metadata">

**Author:** ![ToyotaAE86Trueno](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@ToyotaAE86Trueno](https://forum.arduino.cc/u/ToyotaAE86Trueno)\
**Post date:** [December 18, 2022, 3:29pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/3 "2022-12-18T15:29:07Z")

</div>

so the standalone circuit is this :  
 ![circuit](https://europe1.discourse-cdn.com/arduino/original/4X/1/1/e/11e256ab0d28aeffb25edffbdddb5d7e5adb4bff.png)

and when connected to the mega :

 ![circuit(1)](https://europe1.discourse-cdn.com/arduino/original/4X/4/c/7/4c7b53b583ee3fe610d65dacd5ffe80ec8749878.png)  
pin 11 on the mega i used to produce an 8Mhz clock as said in the first message

---

<div class="post-metadata">

**Author:** ![ToyotaAE86Trueno](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@ToyotaAE86Trueno](https://forum.arduino.cc/u/ToyotaAE86Trueno)\
**Post date:** [December 18, 2022, 3:31pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/4 "2022-12-18T15:31:47Z")

</div>

and when putting back the atmega328 in the uno that it came from and powering the uno from the mega it runs fine (a double the speed because it is using the 16Mhz clock from the uno's crystal).

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [December 18, 2022, 3:32pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/5 "2022-12-18T15:32:43Z")

</div>

Where are the required decoupling capacitors?

See this tutorial [https://www.gammon.com.au/breadboard](https://www.gammon.com.au/breadboard)

---

<div class="post-metadata">

**Author:** ![ToyotaAE86Trueno](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@ToyotaAE86Trueno](https://forum.arduino.cc/u/ToyotaAE86Trueno)\
**Post date:** [December 18, 2022, 3:34pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/6 "2022-12-18T15:34:42Z")

</div>

caps are only required when using an external crystal right? not when using a clock generated by another board nor the internal one? (ok i was talking about the caps for the crystal not the ones you are talking about)

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [December 18, 2022, 3:44pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/7 "2022-12-18T15:44:18Z")

</div>

> [@ToyotaAE86Trueno](#):
>
> caps are only required when using an external crystal right?

Where did you get that silly idea? If you don't have any, that is the problem.

Study the tutorial I linked, add decoupling caps, and let us know how it goes.

---

<div class="post-metadata">

**Author:** ![ToyotaAE86Trueno](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@ToyotaAE86Trueno](https://forum.arduino.cc/u/ToyotaAE86Trueno)\
**Post date:** [December 18, 2022, 3:47pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/8 "2022-12-18T15:47:10Z")

</div>

> [@anon94801460](#):
>
> Where did you get that silly idea?

i never saw someone use them in a tutorial that all.

> [@anon94801460](#):
>
> Study the tutorial I linked, add decoupling caps, and let us know how it goes.

that what i started to do thx.

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [December 18, 2022, 3:48pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/9 "2022-12-18T15:48:23Z")

</div>

You are looking at the wrong tutorials, written by people who have no idea what they are doing. There is every imaginable kind of crap on the web.

---

<div class="post-metadata">

**Author:** ![ToyotaAE86Trueno](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@ToyotaAE86Trueno](https://forum.arduino.cc/u/ToyotaAE86Trueno)\
**Post date:** [December 18, 2022, 3:50pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/10 "2022-12-18T15:50:40Z")

</div>

google just cant recommend good ones.

---

<div class="post-metadata">

**Author:** ![david\_2018](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/david_2018/32/1013044_2.png) [@david\_2018](https://forum.arduino.cc/u/david_2018)\
**Post date:** [December 18, 2022, 3:54pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/11 "2022-12-18T15:54:59Z")

</div>

Well, I tend to trust MCUdude, and the minicore github page specifically says:

> [@](#):
>
> Here is a simple schematic showing a minimal setup using an external crystal. Skip the crystal and the two 22pF capacitors if you're using the internal oscillator.

The clock pins, PB6 and PB7, should just be normal digital I/O pins when using the internal oscillator.

To the OP, do you mean that the internal oscillator functions properly when powered by an external power supply, but not when powered (by 5V) though the Mega?

\< edit \>  
Are you certain the bootloader was burnt using the Internal 8MHz selection, and not External 8MHz?

---

<div class="post-metadata">

**Author:** ![ToyotaAE86Trueno](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@ToyotaAE86Trueno](https://forum.arduino.cc/u/ToyotaAE86Trueno)\
**Post date:** [December 18, 2022, 3:57pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/12 "2022-12-18T15:57:10Z")

</div>

> [@david\_2018](#):
>
> To the OP, do you mean that the internal oscillator functions properly when powered by an external power supply, but not when powered (by 5V) though the Mega?

thats exactly it.

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [December 18, 2022, 4:01pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/13 "2022-12-18T16:01:03Z")

</div>

> [@david\_2018](#):
>
> Here is a simple schematic showing a minimal setup using an external crystal. Skip the crystal and the two 22pF capacitors if you're using the internal oscillator.

That statement is correct. The 22 pF capacitors are the required crystal load caps, and have nothing to do with the decoupling capacitors required elsewhere.

If MCUDude says to leave out the **decoupling** capacitors, that is not correct.

Decoupling capacitors are generally required for all ICs, connected as close as possible between power and GND connections, and anywhere else the manufacturer recommends (like AREF and AVcc in the case of ATmega chips).

---

<div class="post-metadata">

**Author:** ![ToyotaAE86Trueno](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@ToyotaAE86Trueno](https://forum.arduino.cc/u/ToyotaAE86Trueno)\
**Post date:** [December 18, 2022, 4:01pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/14 "2022-12-18T16:01:48Z")

</div>

> [@david\_2018](#):
>
> Are you certain the bootloader was burnt using the Internal 8MHz selection, and not External 8MHz?

yes i am sure about it

---

<div class="post-metadata">

**Author:** ![ToyotaAE86Trueno](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@ToyotaAE86Trueno](https://forum.arduino.cc/u/ToyotaAE86Trueno)\
**Post date:** [December 18, 2022, 4:03pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/15 "2022-12-18T16:03:53Z")

</div>

> [@anon94801460](#):
>
> Decoupling capacitors are generally required for all ICs, connected as close as possible between power and GND connections, and anywhere else the manufacturer recommends (like AREF and AVcc in the case of Arduino).

i didnt know about that.

---

<div class="post-metadata">

**Author:** ![david\_2018](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/david_2018/32/1013044_2.png) [@david\_2018](https://forum.arduino.cc/u/david_2018)\
**Post date:** [December 18, 2022, 4:07pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/16 "2022-12-18T16:07:26Z")

</div>

Sorry, I misunderstood, I assumed the comment was specifically referring to the capacitors on the oscillator pins.

---

<div class="post-metadata">

**Author:** ![david\_2018](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/david_2018/32/1013044_2.png) [@david\_2018](https://forum.arduino.cc/u/david_2018)\
**Post date:** [December 18, 2022, 4:11pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/17 "2022-12-18T16:11:32Z")

</div>

Something definitely seems wrong - with an internal oscillator setting, putting the atmega328 back onto the UNO board should not affect the oscillator, the 16MHz crystal (or resonator) should be totally ignored.

If the fuses are still set for external oscillator, what doesn't make sense is the chip running properly with a breadboard power supply, and no crystal.

---

<div class="post-metadata">

**Author:** ![ToyotaAE86Trueno](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@ToyotaAE86Trueno](https://forum.arduino.cc/u/ToyotaAE86Trueno)\
**Post date:** [December 18, 2022, 4:13pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/18 "2022-12-18T16:13:52Z")

</div>

the low fuses are set to 0xE2 so it should run only on its internal clock

---

<div class="post-metadata">

**Author:** ![ToyotaAE86Trueno](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@ToyotaAE86Trueno](https://forum.arduino.cc/u/ToyotaAE86Trueno)\
**Post date:** [December 18, 2022, 4:22pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/19 "2022-12-18T16:22:43Z")

</div>

i know the chip runs on the 16Mhz crystal when in the uno because the LED is flashing twice as fast compared to when it is out of the board.

---

<div class="post-metadata">

**Author:** ![david\_2018](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/david_2018/32/1013044_2.png) [@david\_2018](https://forum.arduino.cc/u/david_2018)\
**Post date:** [December 18, 2022, 4:25pm UTC](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650/20 "2022-12-18T16:25:25Z")

</div>

I would burn the bootloader again.  
Just to confirm, on a breadboard with no crystal, the LED flashes at the proper rate?

[Next page](https://forum.arduino.cc/t/atmega328p-internal-clock-weirdness/1066650.md?page=2)
