UPDI and Clock Speed

The ATmega4809 microcontroller in the Arduino Nano Every is no longer loaded via a bootloader program, but instead uses a single wire programming interface, Unified Program and Debug Interface, or UPDI. This also has debugging capability, but this is not available with the Arduino IDE.

The ISCP interface (and its 6-pin header) is no longer available. The UPDI pin is permanently connected to the SAM microcontroller that provides the USB connection to the host computer, and the UPDI driver runs on this microcontroller.

A major advantage of this scheme is that the entire program memory is available for applications. Also the fuse bits can be set without having to use a separate AVR-ISP. In particular, the choice of 16MHz or 20MHz clock speeds can be made when loading. 16 MHz is the default, which gives compatibility with the Arduino Nano (or Uno) but, of course, 20MHz will be 25% faster.

To run at 20MHz, add a new board type to the boards.txt file, or modify the existing nona4809 entry. I added a new board “Arduino Fast Every”:

fast4809.name=Arduino Fast Every
 fast4809.vid.0=0x2341
 fast4809.pid.0=0x0058
 fast4809.upload.tool=avrdude
 fast4809.upload.protocol=jtag2updi
 fast4809.upload.maximum_size=49152
 fast4809.upload.maximum_data_size=6144
 fast4809.upload.speed=115200
 fast4809.upload.use_1200bps_touch=true
 fast4809.upload.extra_params=-P{serial.port}
 fast4809.build.mcu=atmega4809
 fast4809.build.f_cpu=20000000L
 fast4809.build.board=AVR_NANO_EVERY
 fast4809.build.core=arduino
 fast4809.build.variant=nona4809
 fast4809.build.text_section_start=.text=0x0
 fast4809.build.extra_flags={build.328emulation} -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP
 fast4809.build.extra_flags=-B{runtime.tools.atpack.path}/gcc/dev/{build.mcu}
 fast4809.bootloader.tool=avrdude
 fast4809.bootloader.file=atmega4809_uart_bl.hex
 fast4809.bootloader.SYSCFG0=0xC9
 fast4809.bootloader.BOOTEND=0x00
 fast4809.bootloader.OSCCFG=0x02
 fast4809.fuses.file=fuses_4809.bin
 menu.mode=Registers emulation
 fast4809.menu.mode.on=ATMEGA328
 fast4809.menu.mode.on.build.328emulation=-DAVR_NANO_4809_328MODE
 fast4809.menu.mode.off=None (ATMEGA4809)
 fast4809.menu.mode.off.build.328emulation=

Code should use the defined constant f_cpu to determine the clock frequency. Welcome to faster execution!