I have been working on this project for quite a while and have tested it extensively. I left the test rig set up, now returning after a month or so, to find I have a serious problem with it described below.
There are two FTDI chips connected to the 4809 40 pin variant (dip on a breadboard with zif socket) One FTDI is used to power the 4809. The hardware ports used are Serial and Serial2 (arduino framework). The baud rate is 19200.
So the problem is that when I powerup the usb hub which hosts the FTDIs, sometimes the system works fine and sometimes it doesn’t. When it doesn’t work Serial is unresponsive and Serial2 produces garbled output, like as if the baud rate is incorrect. If I cycle the power and try again, it works as expected.
Just to make this much more interesting ( ) in the same project box, I have another 4809 which also has two FTDIs connected and this is exhibiting the same problem.
I have used serial a lot over the years on arduino boards, but I am stumped with this. As I mentioned, I tested it to my satisfaction over a period of a week, cycling the power and testing the functionality according to a test plan. It all worked well, so I am at a loss to know what might be the cause of this.
The latest change to the code prior to the testing was to introduce a SPI connection between the two 4809s, which was my first attempt at SPI, but that seemed to work well.
Thanks for any thoughts on this sporadic behaviour and if you need any more info, just let me know.
PIO.ini below
; 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:ATmega4809]
board = ATmega4809
platform = atmelmegaavr
framework = arduino
board_build.variant = 40pin-standard
board_build.f_cpu = 20000000L
monitor_flags =
--echo
upload_protocol = custom
upload_speed = 250000
upload_port = COM3
upload_flags =
-d
atmega4809
-c
$UPLOAD_PORT
-b
$UPLOAD_SPEED
upload_command = pyupdi $UPLOAD_FLAGS -f $SOURCE
lib_extra_dirs =
C:\Users\Paul\Documents\PlatformIO\Projects\Development\
monitor_port = COM3
monitor_speed = 19200
lib_deps =
waspinator/AccelStepper@^1.61
qub1750ul/SoftwareReset@^3.0.0
[platformio]
description = The integrated Stepper Driver