Skip to content
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

UART Baud rate error #140

Open
RobPearce opened this issue Nov 13, 2019 · 1 comment · May be fixed by #162
Open

UART Baud rate error #140

RobPearce opened this issue Nov 13, 2019 · 1 comment · May be fixed by #162

Comments

@RobPearce
Copy link

This could be considered a documentation error.
The Baud rate calculation is wrong as stated. I was trying to reuse a derivative of the module and testing with 1MBaud off a 12MHz clock (divider of 12) and found that the bits were 14 clocks long.
The "cfg_divider" is specified in the README as the simple ratio of clock to Baud.
At line 90 of simpleuart.v (also 84, 97, 130) the bit timing counter is tested for being strictly greater than this and, if so, cleared to zero onthenextclock*. Thus with a divider of 12, the counter cycles through from 0 to 13, giving a total of 14 counts.
The fix, I would suggest, is in two parts. First, change all of those ">" tests to ">=". Second, specify the cfg_divider as (clk/Baud)-1 (which is very common in hardware UART Baud generator registers).

@anishathalye anishathalye linked a pull request May 2, 2020 that will close this issue
@ghost
Copy link

ghost commented Sep 21, 2020

Been playing with a testbench for simpleuart, and can confirm, see screenshot for simplest example with div = 1 (right after reset):
image

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 a pull request may close this issue.

1 participant