-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Subject of the issue
I tried to connect my SPS30 to Serial1 on the RA6M5 but could not get it to work. It turned out that the FIRST receive byte (0x7E) from the SPS30 on RA6M5 Serial1 is lost all the time after reset. But further investigation showed it is worse and it is losing bytes at random.
Your workbench
RA6M5 Sparkfun
Artemis Apollo3 ATP
Ubuntu 22.04
Arduino IDE 1.8.16
Steps to reproduce
To diagnose/reproduce I have created 2 sketches. (included sketches.zip)
One for the RA6M5 (RA6M5.ino) and one for another board. As I used an Artemis ATP I will refer as ATP ( ATP.ino).
Using the core files provided by Sparkfun.
Connect the RA6M5-TX1 to the ATP-RX1, the RA6M5-RX1 to the ATP-TX1 and GND-GND.
Compile the RA6M5.ino on the RA6M5 and the ATP.ino on the ATP.
When you press enter on the RA6M5, a sequence of 6 HEX-bytes (7E 1 2 3 4 7E ) is sent to the ATP. When the ATP has received 2 times '0x7E' it will respond with a different sequence of 6 HEX-bytes.(7E 5 6 7 8 7E) The sending and received bytes are displayed in both sketches.
After a reset of the RA6M5 it will ALWAYS miss receiving the first byte (0x7E) the first time around.
Baudrate impact
When running at 9600 subsequent sending and receiving by the RA6M5 is working correctly.
If you increase the TESTBAUD to 115200 or 230400: 8 out of 10 times it misses one of the 6 bytes sent by the ATP at random!
Notes
I had a Seleae tracer connected and can confirm that every time the ATP has send the complete sequence at the TESTBAUD speed.
As I also own an UNOR4WIFI I have compiled the RA6M5.ino sketch (using the official Arduino library) and did the same test with the UNOR4WIFI : NO BYTES ARE LOST!.
Just to test I have also taken the official Arduino UNOR4 library, added the RA6M5 variant, and updated the boards.txt. After compiling for the RA6M5, Serial1 test results are exactly the same as with the Sparkfun core files.
Remarks
During testing with serialpasstrough the BLE, I had already noticed that sometimes characters were missing in the echo from the DA14531. I had for the time neglected that given we had a different issue to handle, but it looks like Serial2 also has the same issue.
Looking at the source of Serial.cpp, I discovered that the first byte after reset is never passed from the FSP to the WrapperCallback() routine. Looking at the FSP source for the official UNOR4 FSP, there is a lot of code in between for handling an interrupt.
I can't find the fsp configuration files for the Sparkfun libfsp.a as it is not in the place referenced in the core/readme file. Maybe you can provide a link to that ?? According to the file r_sci_art_cfg.h file, in the variant-folder includes/ra_cfg/fsp_cfg, Sparkfun has NOT enabled SCI_UART_CFG_FIFO_SUPPORT and SCI_UART_CFG_FLOW_CONTROL_SUPPORT, where UNOR4WIFI has this enabled. Maybe that is the root cause.
Regards,
Paul