arduino / arduino/ArduinoCore-renesas

Long delay for Serial1.begin() / missing updateBaudRate()

Open
#524 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
193
Forks
112
PR merge metrics
No merged PRs in 30d

Description

I have a [library](https://github.com/gicking/LIN_master_portable_Arduino) which provides LIN communication across a variety of architectures and serial interfaces. To generate LIN BREAK signal, I temporarily reduce the baudrate, send 0x00 and revert to the original baudrate.

However, when porting to Uno R4 Minima I found that changing the baudrate via `Serial1.begin()` and subsequent `Serial1.write()` adds a ~1.2ms pause between BREAK and SYNC, which causes LIN slaves to time-out (see also [here](https://github.com/gicking/LIN_master_portable_Arduino/issues/8)). Specifically `Serial1.begin()` takes ~620µs and (only) the first `Serial1.write()` has a latency of ~520µs.

Can you please check what causes this long latency and improve it? Alternatively add a new method `updateBaudRate()`, similar to ESP32 (see [here](https://github.com/espressif/arduino-esp32/blob/0ed36b09f4ed307b0f0850e38aa2f6f4104a39f6/cores/esp32/HardwareSerial.h#L324C8-L324C22)) with smaller latency? Attached please find a small sketch and screenshots to show what I mean.

Can you please look into that? Thanks a lot in advance!

Looking forward to a lot of fun with the new UNO :-)

[Test_Baudrate_change.zip](https://github.com/user-attachments/files/24844577/Test_Baudrate_change.zip)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the timing with Test_Baudrate_change.zip on the UNO R4 Minima, focusing on Serial1.begin() and the first Serial1.write(). Trace the serial implementation paths used by those calls and compare the measured delay with the LIN BREAK/SYNC timing requirement. Done means the delay is reduced or an appropriate updateBaudRate() API is provided without breaking existing Serial1 behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.