Skip to content

Baudrate correction in Serial is not correctly implemented #45

Closed
@egilkv

Description

@egilkv

How much of a problem this is would depend on the correction of the individual chip.
Async is quite robust to clock accuracy, but we should still try to make the clocks as accurate
we can by using the correction methods in the right way.

The code in the pull request is now in accordance to the data sheet. The previous code would in effect either apply at least twice the compensation, or apply little or no compensation, depending on the sign of the compensation. Finally, as a matter of principle, non-corrected F_CPU is the basis, since that is what is assumed by the correction factors.

I have verified with a frequency counter that the new code gives the most accurate baudrate. On my samples the error was between 0,1% and 0,15%.

##44

To do the test, the following code will work fine since it will give a pattern on the Tx pin equivalent to a square wave of half the frequency of the baudrate:
#https://github.com/arduino/ArduinoCore-megaavr/files/3461514/Test_serial_bug.txt
Change the BAUD to test different frequencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions