I’m a bit stumped by this problem and I must have missed something. Thanks for any advice.
I have a project set up and working on an AVR mega4809 DIP on breadboard - 40 pin variant. The pinouts I have used are here4809 DIP 40 pinout:
The 4809 pins TXD1 and RXD1 are connected to an FTDI chip the Serial1 baud rate is set to 19200 and the monitor speed is also set to 19200 as per PIO.ini below.
I can send and receive via the PIO serial monitor.
So now comes the problem.
I rejigged the serial pin connections on the breadboard to use TXD0 and RXD0 and changed all references to ‘Serial1’ in my code to ‘Serial’ (there are only four references)
As a result of this action the output from the chip to the PIO serial monitor is garbled, the result of
void loop()
{
//todo remove following line
Serial.println("HERE");
is shown below.
legacy Click
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters
--- Miniterm on COM12 19200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
"KHID�C�V*D�im␑D�im␑D�im␑D�i)␑D�im␑D�ii␑D�im␑D�im␑D�im␑D�i)␑D�im␑D�ii␑D�im␑D�ii␑D�im␑D�im␑D�ii␑D�i)␑D�im␑D�im␑D�i)␑D�im␑D�im␑D�im␑D�im␑D�ii␑D�im␑D�ii␑D�im␑D�im␑D�i)␑D�im␑D�i)␑D�im␑D�i)␑D�im␑D�ii␑D�im␑D�ii␑D�im␑D�ii␑D�im␑D�ii␑D�im␑D�im␑D�i)␑D�im␑D�i)␑D�im␑D�ii␑D�im␑D�ii␑D�im␑D�ii␑D�im␑D�ii␑D�im␑D�i)␑D�im␑D�ii␑D�im␑D�im␑D�im␑D�im␑D�im␑D�ii␑D�im␑D�im␑D�im␑D�im␑D�im␑D�ii␑D�im␑D�im␑D�im␑D�ii␑D�im␑D�im␑D�i)␑D�im␑D�im␑D�im␑D�ii␑D�i)␑D�im␑D�im␑D
So normally I would think this is a baud rate issue (in my experience that’s often the cause), but I’ve checked and it’s 19200 in setup()
Serial.begin(19200); // with ASCOM driver refer to DIP 40 pinout to get correct pin numbers for all the serial ports - see the google doc - 'Pin config for Radio Encoder MCU'
Serial1.begin(19200); // with stepper MCU - change this to Serial1 when coding for 4809, see google doc - Pin config for Radio Encoder MCU
Serial2.begin(19200); // with monitor program Change to Serial2 when coding for 4809, see google doc - Pin config for Radio Encoder MCU
I’ve tried changing baud rate in the code to 9600 (also in PIO.ini of course), but the result is the same.
As I’m using the arduino framework for this project, I assume I don’t have to set the chip clock speed?
I’ve also double checked the hardware pin connections and swapped out the FTDI chip for a new one.
thanks for any thoughts on this
PIO.ini below
[env:ATmega4809]
board = ATmega4809
platform = atmelmegaavr
framework = arduino
board_build.variant = 40pin-standard
monitor_flags =
--echo
upload_protocol = custom
upload_speed = 115200
upload_port = COM12
upload_flags =
-d
atmega4809
-c
$UPLOAD_PORT
-b
$UPLOAD_SPEED
upload_command = pyupdi $UPLOAD_FLAGS -f $SOURCE
; Serial monitor baud rate
monitor_port = COM12
monitor_speed = 19200
[platformio]
description = The integrated Azimuth Encoder