arduino / arduino/ArduinoCore-megaavr

Baudrate out of range is silently accepted

Open
#46 7 comments 0 reactions 1 assignee Claimed by @SimonePDA View on GitHub
documentation
Dominant language
C++
Stars
111
Forks
65
PR merge metrics
No merged PRs in 30d

Description

While the original Uno is advertised to support Serial baudrates down to 300, it seems the m4809 can only support baudrates down to 2400. This is due to the design of the baudrate generator, where lower baudrates overflows the 16 bit divider. I have not checked if there are some tricks to circumvent this, other than reducing the CPU clock.

Anyway, with rates lower than 2400 the current code just silently truncates the divisor to 16 bits, causing all sorts of crazy baudrates. Which is really not nice at all, especially for a platform that is beginner friendly.

Other than updating the documentation, what would the right way of handling this be? I noticed in earlier versions of the code there was an internal error flag that simply skipped the entire UART initialization if the baudrate was too high, but that was probably not useful. One option would be to let begin return true/false to indicate problems?

There is also a max baudrate of 1843200 which I guess is less of a practical problem.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.