ATmega328P internal clock weirdness

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 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 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?

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

so the standalone circuit is this :
circuit

and when connected to the mega :


pin 11 on the mega i used to produce an 8Mhz clock as said in the first message

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).

Where are the required decoupling capacitors?

See this tutorial https://www.gammon.com.au/breadboard

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)

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.

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

that what i started to do thx.

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.

1 Like

google just cant recommend good ones.

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

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?

thats exactly it.

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).

yes i am sure about it

i didnt know about that.

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

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.

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

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.

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