Atmel 4809pf pin mapping (dip-40)

Hello
I come from the simple Arduino IDE 2.3.4
No problem with mappings, pins_arduino.h does it for us.

In my setup (will copy below) program compiles and links, but pins belonging to port A work, port C do not.

Project compiles, links and uploads, but PIN10 is not responding.
This is my setup

; 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
; for 4809:

[env:ATmega4809_UART1]
platform = atmelmegaavr
board = ATmega4809
framework = arduino
build_flags = -DF_CPU=16000000L -DVARIANT=40pin-standard
 -I"C:\Users\horac\Documents"
; this path contains the right mapping h file
upload_port = COM3  ; Your specific COM port
upload_speed = 115200
upload_protocol = arduino  ; Use Optiboot for uploading
board_hardware.uart = uart1_def  ; Specify UART1 default pins
monitor_port = COM3
monitor_speed = 115200
build_type = release  ; Enable release mode
;build_type = debug  ; Enable debug mode
lib_deps = 
    duinowitchery/hd44780@^1.3.2
    adafruit/Adafruit BME280 Library@^2.2.4
    adafruit/Adafruit Unified Sensor@^1.1.14
    adafruit/Adafruit BusIO@^1.14.1
    SPI

Thanks for your help and time !
Kind regards

  1. Screenshot of the Arduino IDE “Tools” menu with the settings that worked for you?
  2. Version of the MegaCoreX core version? (Boards → MegaCorex)
  3. Simple code with which you’re testing the pins?

Thanks a lot for your time and help,
I will carefully prepare and come back
Kind regards !

Hello Max,

  1. Screenshot

  1. Version
Processing ATmega4809_UART1 (platform: atmelmegaavr; board: ATmega4809; framework: arduino)
-----------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/ATmega4809.html
PLATFORM: Atmel megaAVR (1.9.0) > ATmega4809
HARDWARE: ATMEGA4809 16MHz, 6KB RAM, 48KB Flash
PACKAGES: 
 - framework-arduino-megaavr-megacorex @ 1.1.2 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 16 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Adafruit BME280 Library @ 2.2.4
|-- Adafruit Unified Sensor @ 1.1.14
|-- EEPROM @ 2.1
|-- hd44780 @ 1.3.2
|-- Wire @ 1.0
Building in release mode
Checking size .pio\build\ATmega4809_UART1\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  30.3% (used 1863 bytes from 6144 bytes)
Flash: [=====     ]  54.8% (used 26930 bytes from 49152 bytes)
  1. Simple code
#include <Wire.h>                  // I2C library
#include <hd44780.h>                // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h>  // I2C support

// Create an instance of the hd44780_I2Cexp class
hd44780_I2Cexp lcd(0x27);  // Replace 0x3F with your LCD's I2C address

void setup() {
  Serial.begin(9600);
  Serial.println("Welcome testing 4809 with IDE 2.3.4");
  Serial.println("Using SDA and SCL on physical pins 34 and 35");
  Serial.println("Using Arduino pin 10 for blinking an Led");
  delay(5000);
  pinMode(10,OUTPUT);
  lcd.begin(20,4);  // Initialize the LCD, 16x2 characters
  lcd.print("Testing pins SDA,SCL,PC2");  // Display a message
  delay(5000);
}
  1. Notes

4.1 With this setup the SDA and SCL lines work, but pin 10 is irresponsive

[env:ATmega4809_UART1]
platform = atmelmegaavr
board = ATmega4809
framework = arduino
build_flags = -DF_CPU=16000000L
upload_port = COM3  ; Your specific COM port
upload_speed = 115200
upload_protocol = arduino  ; Use Optiboot for uploading
board_hardware.uart = uart1_def  ; Specify UART1 default pins
monitor_port = COM3
monitor_speed = 115200
build_type = release  ; Enable release mode
lib_deps = 
    duinowitchery/hd44780@^1.3.2
    adafruit/Adafruit BME280 Library@^2.2.4
    adafruit/Adafruit Unified Sensor@^1.1.14
    adafruit/Adafruit BusIO@^1.14.1
    SPI

4.2 With this setup the SDA and SCL lines do not work, but pin 10 works

[env:ATmega4809_UART1]
platform = atmelmegaavr
board = ATmega4809  ; Keep the board as ATmega4809
framework = arduino
board_build.core = megacorex  ; Specify MegaCoreX as the core
board_build.variant = 40pin-standard  ; Match the 40-pin variant
build_flags = 
    -DF_CPU=16000000L  ; Set CPU frequency to 16 MHz
   -I"C:\Users\horac\.platformio\packages\framework-arduino-megaavr-megacorex\variants\40pin-standard"  
   ; Path for my mapping file
upload_port = COM3  ; Set your specific COM port
upload_speed = 115200  ; Speed for the Optiboot bootloader
upload_protocol = arduino  ; Use Optiboot for uploading
board_hardware.uart = uart1_def  ; Specify UART1 as default
monitor_port = COM3
monitor_speed = 115200
build_type = release  ; Set build type to release
;build_type = debug  ; Uncomment for debug mode
  1. This is the Pinout I am using:

DIP 40 4809 MEGACOREX PINOUT

https://images.app.goo.gl/Y6k7BYQ3bRVoYtNN6

Thanks so much!
Horacio

New information on Dec 6th, 24

  1. This line in pio.ini is ignored:
    board_hardware.uart = uart1_def ; Specify UART1 default pins

If I write uart0, or uart2 system compiles, links and upload normally.
PIO is taking the default as uart0, and I am connecting Tx and Rx to the uart0 line in pins PA0 and PA1.

  1. By try and error, i know that the port PD is well mapped. If i use PD0 to PD7 as Arduino numbers A0 to A7 the eight pins drive an led normally.
  2. In short: with the setup in 4.1 SDA and SCL work, Port A and Port D work.

Thanks again,
Kind regards

Hello,

Just a short advice request to more experienced users.
This post has some days without solution.
Perhaps is too time consuming or not a frequent subject. I don’t know.

Do you think it could be a matter of interest for all our community to have an out-of-the-box example to install PIO with Dip-40 version mapping correctly?

If you think so, I can open an issue on Git, and offer my time to test it.

Thanks so mush for your guidance !
Kind regards !
Horacio