Arduino Uno with 8MHz bootloader (not on breadboard !)

Hi everyone!

I need to put my Arduino Uno Board in 8Mhz, for testing on some complex programs using many I2C connexions.

But... I only find tutorials to put arduino Uno on 8Mhz on breadboard !

Is there a way to put my arduino Uno board in 8Mhz ? Just with my PC, a USB cable and my only one Arduino Uno ?

Thanks you for yours futurs answers,

ZCHF

I don't think so. You would need a ICSP programmer such as USBasp, or a second Arduino of some kind, to change the clock to 8MHz internal clock and burn the 8MHz bootloader.

If your Uno is an R3 (with removable chip) you could buy a blank atmega328-p, you can use the Uno to load the settings and bootloader for 8MHz internal clock into the new chip, them swap the chips over.

Before you do anything else, load up ebay and buy a couple of cheap clone Arduino - uno’s or nano’s (I find the nano more convenient - buy I also despise the male dupont jumpers). Stuff happens, and you don’t want to have your project put on hold for weeks for that. Heck I let the smoke out of a nano just a couple days ago. should have put the housing on the dupont jumper before plugging it in (power and ground were touching, and it was a nano with that undersized diode that’s easy to burn out. Particularly annoying, because it was an unusually nice nano clone, and I’d just been thinking about how nice it was when I plugged it in and smoke came out.)

Okay, now that you’ve ordered a couple of cheap replacements for when (not if) you trash your board

If you just need the board running at 8MHz (not the 8MHz bootloader, then it’s easy-peasy… the annoying part is going to be uploading - but even that’s not too bad… Install MCUDude’s MiniCore, that gives you an 8MHz board def ready to go no baggage…

With verbose upload enabled in preferences, do an upload with 16MHz selected (doesn’t matter what sketch, of course, it should upload no problem). Scroll up in the console window to find the avrdude invocation, something like this:

C:\Users\Pete\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\Pete\Documents\Arduino\hardware\MiniCore\avr/avrdude.conf -v -patmega328p -carduino -PCOM11 -b115200 -D -Uflash:w:C:\Users\Pete\AppData\Local\Temp\arduino_build_665436/jtag2updi.ino.hex:i

(of course, different paths, different sketch names).

Copy-paste it into a text editor.

Now, go to your real sketch, select an 8MHz board definition.Don’t bother trying to upload them (they won[t upload successfully, because the 8MHz bootloader uses a different baud rate - but you’re uploading to an 16MHz board; may or may not be worth it to actually make a board def for this; that’s beyond the scope of this post). To make your board run at 8MHz instead of 16, we just want to divide the clock by 2, starting as soon as we can. At the beginning of setup, do:

cli();
CLKPR=1<<CLKPCE;
CLKPR=1<<CLKPS0;
sei();

That sets the prescaler to 2. And since you’re compiling for 8MHz, but the board has 16MHz crystal, as soon as your sketch starts running, that will halve it’s clock speed so it will be running at the desired 8.

To upload that:

Sketch → export compiled binary

Sketch → Show sketch folder

Copy-paste the name of sketch and the path to the folder into that text file.

Replace the path to the .hex in the original avrdude invocation with that one, save it, and paste it into a command window (could even make it a batch file if you’re going to be doing this alot with one sketch name)

Thanks you very much for your answers ! I will do this

ZCHF