[Atmega324PB] Problems with clock setting

I have a .ini file which worked fine till last week, but behaves strange now when i’m trying to upload to my board with an Atmega324PB and a 20Mhz external clock.

This is a part of the ini file:

for old Board

#board_build.f_cpu = 8000000L
#board_fuse.lfuse = 0xD2
#board_fuse.hfuse = 0xD1
#board_fuse.efuse = 0xFC

for new Board

board_build.f_cpu = 20000000L
board_fuse.lfuse = 0xC0
board_fuse.hfuse = 0xD1
board_fuse.efuse = 0xFC

I got following error message, when i try to compile with the settings from the new Board

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/ATmega324pb.html
PLATFORM: Atmel AVR (3.0.0) > ATmega324PB
HARDWARE: ATMEGA324PB 16MHz, 2KB RAM, 31.50KB Flash
PACKAGES:

  • framework-arduino-avr-mightycore 2.0.8
  • toolchain-atmelavr 1.50400.190710 (5.4.0)
    Error: This board doesn’t support board_build.f_cpu = 20000000L framework!

When i change the lfuse value to the value from the old board, everything compiles fine, but the fuse settings are then not correct.

Does anyone have an idea whats wrong about the ini file, the fuse settings or anything else

Weird since it reports using the Arduino framework package above but then throwing this error. Can you post the full platformio.ini?

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:ATmega324PB]
platform = atmelavr
board = ATmega324pb
framework = arduino

# for old Board
board_build.f_cpu = 8000000L
board_fuse.lfuse = 0xD2
board_fuse.hfuse = 0xD1
board_fuse.efuse = 0xF7

# for new Board
# board_build.f_cpu = 20000000L
#board_fuse.lfuse = 0xE0
#board_fuse.hfuse = 0xD1
#board_fuse.efuse = 0xF7

upload_protocol = custom
upload_port = usb
upload_flags =
    -C
    $PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
    -p
    $BOARD_MCU
    -P
    $UPLOAD_PORT
    -c
    avrispmkII
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

I don’t get any errors when either using the platformio.ini you provided or uncommenting the options for the new board and commenting the ones for the old board, leading to

[env:ATmega324PB]
platform = atmelavr
board = ATmega324pb
framework = arduino

# for old Board
#board_build.f_cpu = 8000000L
#board_fuse.lfuse = 0xD2
#board_fuse.hfuse = 0xD1
#board_fuse.efuse = 0xF7

# for new Board
board_build.f_cpu = 20000000L
board_fuse.lfuse = 0xE0
board_fuse.hfuse = 0xD1
board_fuse.efuse = 0xF7

upload_protocol = custom
upload_port = usb
upload_flags =
    -C
    $PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
    -p
    $BOARD_MCU
    -P
    $UPLOAD_PORT
    -c
    avrispmkII
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

Make sure there is not a leading space in front of board_build.f_cpu = .. otherwise it will be seen as a continuation of the last directive.

1 Like

Thanks for the hint! I searched for misplaced spaces and now it compiles without errors.