[Solved(?)] Having troubles getting ATMEGA328P-PU to run on internal oscillator.

Hello! This is my first post in this community.

I have searched for my issue through this forum, through Google, and through YouTube and while I can find plenty of guides and plenty examples of everything working perfectly fine or plenty of examples of people having other types of issues, I can't seem to find any examples of people having the same issue I am having. I hope someone here can help.

In summary, I am trying to get the ATMEGA328P-PU to run standalone on a breadboard using the internal 8MHz oscillator instead of using an external oscillator. I have taken inspiration from these sources: https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard http://oddwires.blogspot.com/2012/06/burning-bootloader-into-bare-atmega328.html http://highlowtech.org/?p=1706 https://www.youtube.com/watch?v=jP1NTgs-a-s https://www.youtube.com/watch?v=e_DoHqcENSs http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf

I have successfully used another Arduino as an In-System Programmer, but I prefer to use my MiniPro TL866 universal programmer since it is just much simpler, gives me more control, and requires much less wires and messing around. Either way, the result is the same and I have exhausted all avenues which are apparent to me.

In summary, the issue I have is that if I try to program the ATMEGA328P to use internal oscillator via Arduino as an ISP [u]or[/u] if I use the TL866 universal programmer to set the fuse bits manually, the ATMEGA328P doesn't seem to properly start up. I placed the blink sketch in code memory, and the ATMEGA328P runs the blink sketch just fine with an external oscillator. If all I do is set the fuse bits to use the internal oscillator instead of the external oscillator, the blink sketch never starts up. If I simply change the fuse bits back to use the external oscillator, the blink sketch starts up fine. During that process, I never once modified the blink sketch and never once had to re-flash the blink sketch to get it to work. It is simply (not that simple after all!) an issue that the ATMEGA328P does not seem to start using the internal oscillator.

Is the internal oscillator defective? Am I doing something wrong? What in the world!?

This is my low fuse setup: Fuse Low Byte is set to: 01100010 which is 0x62 This setup should be correct to make the chip run on an 8MHz internal oscillator, the slowest boot time to allow the oscillator to stabilize, option to use the clock output on PORTB0 if I ever wanted it to communicate/sync with another chip, and not divide the clock speed by 8.

I have also tried with clock divide by 8 enabled and with CKOUT on PORTB0 disabled. The problem remains.

This is my high fuse setup: Fuse High Byte is set to: 11011001 which is 0xD9 This setup should be correct for external reset disabled, debug wire enabled, serial programming and download enabled, watchdog timer always on, EEPROM not reserved from chip erase, and maximum boot size.

Do you see anything wrong with that setup? I have also tried adding #DEFINE F_CPU 1000000UL to the beginning of the blink sketch in case it was confused or unstable from the clock change. Makes no difference though. The blink sketch simply will not run (LED always off) if the internal oscillator is enabled. If toggled back to external oscillator using fuses and connected to an external oscillator, it runs fine. I have even cleared the chip completely, removed the Arduino boot loader, tried the whole process and every combination I could think of over again, had the same problem, put the Arduino boot loader back on it, connected it back to an Arduino Uno board, uploaded Arduino sketches to it just fine like usual, and continued to use it as a normal Arduino board without any issues. So, the chip seems to be working fine in the Arduino environment in every way and also works fine on a breadboard as long as an external oscillator is used.

I am stumped. Is it possible to receive a version of the chip with defective or missing internal oscillator? Do I need to connect a capacitor across VCC and VSS to stabilize the chip for some reason during boot? Any other reason?

Sorry that my first post is so long and so needy. I hope that it is not too long but is also clear and detailed enough. Thank you for any help!

ty_ger07: This is my high fuse setup:.......

Do you plan to burn your program directly into the 328 (i.e. not using a bootloader)?

If so, then set the fuses like this:

[b]EFUSE: 0xFF
HFUSE: 0xDF
LFUSE: 0xF2[/b]

This will give you an 8 mhz internal (RC) clock, CKDIV8 off and CKOUT off and reset vector jumps to 0x0000 (i.e. no bootloader).

Good luck.

Well.... huh!?!

I guess I must not fully understand what I am doing; or not doing. Now it is working and I don't know what changed.

As described in the original post, I was previously primarily using: LFUSE: 0x62 HFUSE: 0xD9 EFUSE: 0xFF

But I did also try other combinations; every combination I could think of which did or did not make logical sense to me. I also tried while preserving the bootloader or after erasing the chip and not preserving the bootloader.

I have used your suggestion specifically (even though I think that your suggestion is one of the combinations I have already tried): LFUSE: 0xFF HFUSE: 0xDF EFUSE: 0xFF

.... And it worked! It worked with or without the bootloader preserved at the end of code memory.

I then tried: LFUSE: 0xFF HFUSE: 0xD9 EFUSE: 0xFF

And it worked with or without the bootloader present at the end of code memory.

I then tried (the original combination I was primarily trying to use): LFUSE: 0x62 HFUSE: 0xD9 EFUSE: 0xFF

And it worked (at a slower blink speed of course).

So.... ?? I don't get it. No combinations worked before. Now all combinations are working. Consider this solved but also puzzling. The wiring is the same. The method of programming is the same. The values are the same. But now it is working and before it was not working. I am very... :relaxed: .

I think you'll benefit from using MiniCore instead! It's an Arduino core for the ATmega328 (and the rest of the x8 family) where you can choose in the boards menu to use the internal (1 or 8 MHz) or external oscillator (8, 12, 16 or 20 MHz). If you choose to use the internal oscillator it actually gives you two additional IO pins, remapped as digital pin 20 and 21! :D

|500x315