Hello Max,
- Screenshot
- 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)
- 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);
}
- 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
- 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
- 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.
- 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.
- In short: with the setup in 4.1 SDA and SCL work, Port A and Port D work.
Thanks again,
Kind regards