Skip to content

Fix bug in baudrate compensation. #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 16, 2019
Merged

Conversation

egilkv
Copy link
Contributor

@egilkv egilkv commented Aug 2, 2019

The code is now in accordance to the data sheet. The previous code would in effect either apply twice the compensation, or apply no compensation, depending on the polarity of
the compensation.
For how to correctly calculate baudrate compensation, see for instance the megaAVR 0-Series Manual chapter 9.3.4.1

I have verified this by running this program: https://github.com/arduino/ArduinoCore-megaavr/files/3461514/Test_serial_bug.txt
It allows one to verify the exact baudrate with a frequency counter. With the correct code, the error I recorded with my sample was 0,15%. With the original code, 0,3%-

egilkv added 3 commits August 2, 2019 16:18
data sheet. The previous code would in effect either apply twice the
compensation, or apply no compensation, depending on the polarity of
the compensation.
It is now exactly the same as in the documentation.
The net result is the same as the previous version.
the right baudrate, then we should use F_CPU, the specified CPU
frequency as basis, not the F_CPU with whatever corrections.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants