-
Notifications
You must be signed in to change notification settings - Fork 12
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
Allow any baud rate; not just a restricted set #41
Conversation
Fixes ARMmbed#40. I'm pretty sure the rounding is unnecessary (i.e. the hardware rounds / truncates anyway), but I did it anyway so the values match the Nordic header.
Automatic CI verification build not done, please verify manually. |
Automatic CI verification build not done, please verify manually. |
// Round it to 20 bits (see link above). | ||
br = (br + 0x800) & 0xFFFFF000; | ||
|
||
// Limit it to the valid range. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the valid range defined? From the nRF51 ref manual any 32-bit value seems to be accepted.
Here is the code I used to test it. It's Matlab/Octave rather than C, but it is the same maths.
Test:
Output:
Correct values:
Looks like the 921600 value has been rounded in the latest code. My value is very slightly different, but it shouldn't matter in practice (it's a 0.002% difference). It seems pretty clear from the datasheet to me that the maximum rate is 1 Mbaud, especially as 1 Mbaud gets a special value (0x10000000). The minimum rate is due to the rounding (I don't think anyone will want to go as low as 15 baud anyway!). |
Fixes #40.
I'm pretty sure the rounding is unnecessary (i.e. the hardware rounds / truncates anyway), but I did it anyway so the values match the Nordic header.