RE: [PATCH 5/5] can: bittiming: can_calc_bittiming(): use Phase Seg2 / 2 as default for SJW

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Marc,

> In other words this means the SJW parameter controls the tolerance of
> the CAN controller against the frequency error compared to other CAN
> controllers.
> 
> If the user space doesn't provide a SJW parameter, the kernel chooses
> a default value of 1. This proved to be a good default value for CAN
> controllers, but not anymore with modern controllers.
> 
> 
> To get the same oscillator tolerances on controllers with wide bit
> timing registers, choose a default SJW value of Phase Seg2 / 2. This
> results in the following bit timing parameters:


Thanks for your work on this! May I ask why Phase Seg2 / 2 is chosen?

In general the recommendation is to chose SJW as big as possible. Here's an excerpt from the CiA 601-3 (Unfortunately I can't share the entire document) 
"Recom2: Choose sjwA as large as possible. 
- The maximum possible value is sjwA = min(ps1A, ps2A). 
- During arbitration phase, a large sjwA allows a CAN node to resynchronize quickly on the leading transmitting node. 
- If the CAN controller does not allow configuring the maximum possible sjwA 
because the value range for sjwA is limited in the CAN controller, then consider 
increasing BRPA. This allows configuring a larger sjwA, unless this can impact 
phase error tolerance in an unwanted way, see Recom4."

I think we discussed this a while ago already and the biggest reasoning against maxing SJW was breaking "compatibility" to old kernel versions. The compatibility in this is not being able to sync though...
Now, if a change to a larger default values is agreed upon we might as well chose min(phaseseg1, phaseseg2) directly to maximize robustness for the user that doesn't set it explicitly. Given that most of the getting started with Socketcan results on your favorite Search engine don't even mention SJW that's probably a significant portion of the users. From a pure communication standpoint I can't see any downside to doing this, the only hypothetical case would be if a CAN controller had an erratum about higher SJWs and the driver not handling it.

So, in essence, I'd propose to use min(p1,p2).

Best Regards,
Thomas




[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux