-
Notifications
You must be signed in to change notification settings - Fork 2.1k
sys/can: improve SJW calculation #21756
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
base: master
Are you sure you want to change the base?
Conversation
sys/can/device.c
Outdated
timing->sjw = SJW; | ||
} | ||
else { | ||
if (!timing->sjw) { |
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.
To facilitate validation for any reader, it would be valuable to have the CIA paper reference here as a comment.
sys/can/device.c
Outdated
timing->sjw = SJW; | ||
} | ||
else { | ||
if (!timing->sjw) { |
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.
SJW must not be bigger than phase segments 1 and 2. If a value is provided, not probing for phase segment 2 would leave the possibility that sjw is larger than segment 2.
if (!timing->sjw) {
timing->sjw = timing->phase_seg2;
}
else {
timing->sjw = MIN(timing->sjw, timing->phase_seg2);
}
timing->sjw = MIN(timing->sjw, timing->phase_seg1);
timing->sjw = MIN(timing->sjw, timing_const->sjw_max);
Contribution description
SJW was defaulting to 2 -> good for 8MHz time quanta bad for higher clock
With this PR:
This should usually end up with SJW being the same as phase 2 for can configuration having the sample point at 87.5%) ->
it's starting at value of phase 2 making changes by the following comparisons unlikely.
Testing procedure
read
run can and see improved stability of connection for slightly drifting clocks on either end (less failed frames due to synchronization issues).
Issues/PRs references
http://www.oertel-halle.de/files/cia99paper.pdf might help under standing the sjw value