Hello,
I am having an issue that I am hoping someone can help with or at least provide troubleshooting guidance. I wrote an Arduino sketch for the Nano Every that uses the "Serial1" port (digital pins 0 and 1). The sketch and serial1 communication works fine when I program it onto my Arduino Nano Every board. But I created my own PCB with the AT4809 microcontroller on it and when I write my Arduino sketch onto the AT4809 microcontroller the serial1 communication prints out nonsense characters. I am writing the code onto my AT4809 microcontroller on the PCB using the Atmel ICE programmer, the Arduino IDE hex file, and Microchip Studio software. Other functions seem to work but the serial communication is always printing out as non-sense characters (it does print out something). Here are some things I tried and checked:
- I checked the fuse settings for the AT4809 in Microchip studio and the clock was set for 20MHz
- I tried different baud rates with the same outcome
- I tried using the software serial library and I get same results (works on Nano Every but on my design prints garbage)
- I tried compiling the code with both the ATMEGA328 register emulation and without any register emulation
- My hardware design is not using any external oscillators, just the internal AT4809 oscillator just like the Nano Every
- Unfortunately my design does not have access to the "Serial" port that the Nano Every has connected to to the USB port.
I wrote a simple "Serial1" test program for troubleshooting purposes. See that code below, once again the below code runs fine on the Nano Every but prints out garbage when burned onto my PCB design. I suspect the issue is a clock problem or the UART port is not configured correctly since I am getting data in the serial terminal, it is just garbage characters. But I don't understand why things would be different if my fuses match and I am using the Arduino IDE Hex to program. Any help would be greatly appreciated.
My test code:
void setup() {
Serial1.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial1.println("testing serial1.......");
delay(500);
}