Arduino Uno, lower clock to 8MHz [internal]

Hi there,

I’ve been digging through forums but was not able to find a solution.

Final result: low power ATmega328 sensor node powered by 2xAA batteries.

Current goal: take out original ATmega328 chip from Arduino Uno v3 board [externally clocked @ 16MHz] and switch it to another ATmega328 clocked internally @ 8MHz and have it working as a slowed down original.

So far I’ve managed to build a circuit and flash original Arduino Uno bootloader to a fresh chip. Switching newly flashed chip for the original one worked great [ was able to flash program and run it, @ 16MHz of course].

Unfortunately all my attempts at switching ATmega to 8MHz yield no results. 1.6.5 IDE gives endless timeouts while 1.0.1 gives avrdude: stk500_getsync(): not in sync: resp=0x00 error.

I have tried the following setups, X = 57600, 38400, 9600

  1. Copy of original settings of Arduino Uno, fuses changed to use internal 8MHz oscillator and lower dropout voltage
    unolp.name=Arduino/Genuino Uno [ 8MHz / low power ]
    unolp.upload.tool=avrdude
    unolp.upload.protocol=arduino
    unolp.upload.maximum_size=32256
    unolp.upload.maximum_data_size=2048
    unolp.upload.speed=X

unolp.bootloader.tool=avrdude
unolp.bootloader.low_fuses=0xE2
unolp.bootloader.high_fuses=0xDE
unolp.bootloader.extended_fuses=0x06
unolp.bootloader.unlock_bits=0x3F
unolp.bootloader.lock_bits=0x0F
unolp.bootloader.file=optiboot/optiboot_atmega328.hex

unolp.build.mcu=atmega328p
unolp.build.f_cpu=8000000L
unolp.build.board=AVR_UNO
unolp.build.core=arduino
unolp.build.variant=standard


guide: Low-Power Wireless Sensor Node | maniacbug
bootloader file: arduino-core-files/ATmegaBOOT_168_atmega328_pro_8MHz.hex at master · codebendercc/arduino-core-files · GitHub

lopower.name=Arduino Ultru Low-Power (<2.4V, 8 MHz) w/ ATmega328

lopower.upload.protocol=stk500
lopower.upload.maximum_size=30720
lopower.upload.speed=X
lopower.upload.tool=avrdude

lopower.bootloader.low_fuses=0xE2
lopower.bootloader.high_fuses=0xDA
lopower.bootloader.extended_fuses=0x06
lopower.bootloader.path=atmega
lopower.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
lopower.bootloader.unlock_bits=0x3F
lopower.bootloader.lock_bits=0x0F
lopower.bootloader.tool=avrdude

lopower.build.mcu=atmega328p
lopower.build.f_cpu=8000000L
lopower.build.core=arduino
lopower.build.variant=arduino:standard

What else can I do to have the chip running @ 8MHz on the Uno board ? Any help appreciated.

Thanks.

Hi,

Can you straighten a few things out? Are you trying to run the atmega @8MHz on the Uno board, or on something else, e.g. breadboard?

If on the Uno board, are you trying to power that with the 2AA batteries, or with USB power?

If on a breadboard, what are you using as the usb-serial adaptor? The Uno with its socket empty?

Paul

I shouldn't have mentioned running it on batteries. That is a future goal and introduced confusion.

For now, goal: Arduino Uno board + ATmega328@8MHz, internal oscillator, powered via USB - no breadboard.

I am using a breadboard to program bootloader, using "Arduino as ISP" programmer. Then I remove the original chip from Arduino board, disconnect the breadboard and put newly flashed chip on the Uno board.

If you're using the same bootloader hex used for the Uno (looks like you are), you need to set upload.speed to half of what it is for the Uno, ie

(boardname).upload.speed=57600

I suspect there are also wiring issues, though, since it's getting resp:00, not something else. Check that TX/RX are the right way around, and that the chip's fuses are set correctly (ie, not set to use external crystal)

Changed fuses to use internal oscillator, changed upload speed to 57600, 38400, 9600 still no difference.
Have no extra wiring, after flashing bootloader I disconnect everything from Uno board, remove chip from Uno, put newly flashed chip on Uno [ that works for original bootloader, so programmer is ok ].

What if you leave the 8MHz chip on the breadboard, remove the chip from the Uno and connect only ground, 5V, rx & tx from the uno to the breadboard?. Don't forget 10K pull-up on the reset pin and a 0.1uF bypass cap on the breadboard.

Ultimately, you don't want to use the UNO board for battery power. Its leds, regulator and serial chips will only waste battery power. Running at 4MHz or 1MHz will give longer life still, but you must either compile a 4MHz or 1MHz hex file version of the bootloader, or abandon serial programming and always use isp programming.

Sure, don't want to use batteries to power Arduino Uno board.

What i wanted to do is to make low power sensor node based on underclocked ATmega328. So make ATmega328 use its internal 8MHz oscillator [or additionally /8 divider to achieve 1MHz], be able to program it on Arduino Uno board and be able to monitor serial data using IDE [ so i could do some debugging printfs and see results ].

Then remove chip from Arduino Uno and move to breadboard. Use AA batteries to power it and pray for it to work.

--

Unfortunately ran out of capacitors. Will get some more tomorrow as well as an external oscillator in case there's something seriously wrong with the internal one. Well, time to clean this mess up for today, hate seeing wires laying around in the morning.

Or better yet use the 16MHz crystal and just divide it by 2 with software settings. Using a crystal works better for serial. Modify Optiboot by adding a couple of lines of code to divide the clock in half at the beginning of the code, right before the Adaboot no-wait mod.

  CLKPR = (1 << CLKPCE);
  CLKPR = 0x01;

Then compile Optiboot with the options: BAUD_RATE=58823 AVR_FREQ=8000000L
You can then create a custom boards.txt entry with upload.speed=57600 and build.f_cpu=8000000L

The reason for compiling with that weird baud is explained here:

My custom boards.txt entry for Uno operating at 8MHz using the 16MHz crystal:

unob.name=ATmega328P-based Arduino Optiboot 16MHz divided by 2 for 8MHz
unob.vid.0=0x2341
unob.pid.0=0x0043
unob.vid.1=0x2341
unob.pid.1=0x0001
unob.vid.2=0x2A03
unob.pid.2=0x0043
unob.upload.tool=arduino:avrdude
unob.upload.protocol=arduino
unob.upload.maximum_size=32256
unob.upload.maximum_data_size=2048
unob.upload.speed=57600
unob.bootloader.tool=arduino:avrdude
unob.bootloader.low_fuses=0xFF
unob.bootloader.high_fuses=0xDE
unob.bootloader.extended_fuses=0x05
unob.bootloader.unlock_bits=0x3F
unob.bootloader.lock_bits=0x0F
unob.bootloader.file=optiboot_atmega328_58823_CLKPR1-16-to-8MHz.hex
unob.build.mcu=atmega328p
unob.build.f_cpu=8000000L
unob.build.board=AVR_UNO
unob.build.core=arduino:arduino
unob.build.variant=arduino:standard

optiboot.zip (1022 Bytes)

Well, I shouldn't have said "better yet." It is only better in the sense that you can do development on your Uno without hardware-modifying it. The final configuration on the breadboard can use an 8MHz crystal.

Thanks for input guys.

Tried to connect Rx,Tx,RESET + 5V Vcc but still not able to program the chip [no sync error, internal oscillator].

I've tried dmjlambert's suggestion (more convenient, uC on the Uno board) to divide clock frequency using software approach [ compiled bootloader myself yay :wink: ] - works like a charm.

For "production" board i think i'll just use external oscillator anyways, safer.

But that's another step. I'll report progress or lack thereof.

Cheers.

Wire up the chip like here

and bootload it to use internal 8 MHz oscillator.

Lil update: Used external oscillator. Now I am able to program the chip on breadboard using Uno Board [Rx,Tx,RESET, 10k pull up and 0,1uF cap].

Added NRF24L01+ module, connected 2xAA batteries, so far so good.