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

CAN bit rate enhancement #297

Open
fastbike opened this issue Apr 29, 2024 · 0 comments
Open

CAN bit rate enhancement #297

fastbike opened this issue Apr 29, 2024 · 0 comments
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@fastbike
Copy link
Contributor

Following on from #295

Here's another small code change to the CAN baud rate calculation to support the allowable error between the theoretical bit rate and the calculated bit rate to be an absolute value.

Current behaviour for a theoretical bus speed of 16,666.666' shows the following states:

  • CAN.begin(16666) succeeds - the absolute error is 0.003200128
  • CAN.begin(16667) fails - even though the absolute error is smaller at 0.001599968

Code change is required in CanUtil.cpp ...

    /* If the fractional part is sufficiently close to zero, we have
     * found a valid prescaler configuration.
     */
    if (brp_fract < 0.01)

... it should be checking either side of the desired rate

    /* If the fractional part is sufficiently close to zero, we have
     * found a valid prescaler configuration.
     */
    if (brp_fract < 0.01 || brp_fract > 0.99)
fastbike added a commit to fastbike/ArduinoCore-renesas that referenced this issue Apr 29, 2024
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Apr 29, 2024
@per1234 per1234 linked a pull request Apr 29, 2024 that will close this issue
aentinger pushed a commit to fastbike/ArduinoCore-renesas that referenced this issue May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants