Using the IDE for a Atmel ATmega328PB Xplained Mini caused wrong timings

Hi to all.

I'm using Arduino IDE for the Atmel ATmega328PB Xplained Mini board. I download the skteches via an AVRISP MKII. Everything is working OK as long as I use the 5 Volt supply voltage.

When I switch to 3.3 Volt (via Jumper settings) the clock rate is automatically reduced from 16 MHz to 8 MHz at boot time. This causes all timings to be doubled, e.g. millis() resolution is now 2 ms, a serial interface must be initialized with 19200 Baud to work at real 9600 Baud, I2C transfer rate is halved, etc. So the system is still initialized for 16 MHz by the Arduino libraries.

I looked everywhere if I can find a setting, something like a clock divider, but was not able to solve the problem. Does anyone have an idea how to overcome the wrong timings at 8 Mhz?

Regards,
Dirk.

I just found a solution in a different thread, mybe the solution is helpful for somebody else: One can set the clock frequency by adding a menu entry to the Arduino IDE:

https://tttapa.github.io/Pages/Arduino/Bootloaders/ATmega328P-custom-frequency.html

In my case I had to add/modify the following the following lines of the boards.txt file:

#--------------------------------------------------------------------------------------#

atmega328pb_xplained_mini.name=Atmel atmega328pb Xplained mini

atmega328pb_xplained_mini.vid.0=0x03eb
atmega328pb_xplained_mini.pid.0=0x2145

atmega328pb_xplained_mini.upload.tool=arduino:avrdude
atmega328pb_xplained_mini.upload.protocol=arduino
atmega328pb_xplained_mini.upload.maximum_size=32256
atmega328pb_xplained_mini.upload.maximum_data_size=2048
atmega328pb_xplained_mini.upload.speed=57600

atmega328pb_xplained_mini.bootloader.tool=arduino:avrdude
atmega328pb_xplained_mini.bootloader.low_fuses=0xE0
atmega328pb_xplained_mini.bootloader.high_fuses=0xDE
atmega328pb_xplained_mini.bootloader.extended_fuses=0xFC
atmega328pb_xplained_mini.bootloader.unlock_bits=0x3F
atmega328pb_xplained_mini.bootloader.lock_bits=0x0F
# atmega328pb_xplained_mini.bootloader.file=optiboot/optiboot/bootloaders/optiboot/optiboot_xplained328pb.hex

#atmega328pb_xplained_mini.build.mcu=atmega328pb # needs AVR GCC toolchain update
atmega328pb_xplained_mini.build.mcu=atmega328p
#atmega328pb_xplained_mini.build.f_cpu=16000000L
atmega328pb_xplained_mini.build.board=AVR_ATMEL_ATMEGA328PB_XMINI
atmega328pb_xplained_mini.build.core=arduino:arduino
atmega328pb_xplained_mini.build.variant=atmega328pb-xmini

menu.speed=CPU Speed

atmega328pb_xplained_mini.menu.speed.16=16 MHz
atmega328pb_xplained_mini.menu.speed.8=8 MHz
atmega328pb_xplained_mini.menu.speed.16.bootloader.file=optiboot/optiboot/bootloaders/optiboot/optiboot_xplained328pb.hex
atmega328pb_xplained_mini.menu.speed.8.bootloader.file=optiboot/optiboot/bootloaders/optiboot/optiboot_xplained328pb_8.hex
atmega328pb_xplained_mini.menu.speed.16.build.f_cpu=16000000L
atmega328pb_xplained_mini.menu.speed.8.build.f_cpu=8000000L

#--------------------------------------------------------------------------------------#

I'm workin under Linux and the boards.txt file for the AVR development board can be found in the hiden folder:
.arduino15/packages/atmel-avr-xminis/hardware/avr/0.6.0/boards.txt

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.