This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
If I select the following 1Mbps configuration in SYSCONFIG:
...the following code is generated:
CAN_setBitTiming(MAIN_CAN_BASE, 7, 0, 15, 7, 2);
There's a direct numerical mapping between the GUI contents and the arguments to CAN_setBitTiming(). Unfortunately this function updates the register with the arguments directly which means that the Tq values are not converted to the register values correctly.
For example, "(Re)Synchronization Jump Width (Tq)" = 2 should set CAN_BTR.SJW = 1 since actual SJW = CAN_BTR.SJW + 1.
The purpose of the SYSCONFIG (I think) is to abstract the design parameters, in this case Tq, from the register contents but this does not seem to be the case for CAN bit timing.
Kier,
You are 100% correct with the purpose of SysConfig. I am looping in the MCAN experts.
SysConfig and driverlib should work together to update the registers correctly.
Sahil Deshpande can you review how the values are calculated in SysConfig, how they are generated in the CODE and how driverlib uses these values to update the registers?
Thank you,
Nima Eskandari
C2000 Application Manager
Many thanks everyone.
Perhaps the SysConfig GUI auto calculation mode should use the same formulae and inputs as Hareesh's Excel calculator (https://www.ti.com/lit/pdf/SPRAC35)?
Just a suggestion.
Sahil Deshpande did you take a look at this? we can provide a fix in the next C2000WARE release.
Kier,
I apologise for the late response.
The values that can be seen as parameters to the function, are actually corrected in order to be fed to the registers directly.
The issue here is with the naming of the fields. In this specific example, (Re)Synchronization Jump Width (Tq) is actually 3, which in turn sets CAN_BTR.SJW to 2.
Thanks for pointing this out. I will update Sysconfig so that the fields will read the actual values, and not the corrected values, which in turn are the parameters to the function CAN_setBitTiming().
Thanks.
Sahil,
Thanks for the reply.
The values that can be seen as parameters to the function, are actually corrected in order to be fed to the registers directly.
If by "corrected" you mean calculated by SYSCONFIG from Bit Rate and SYSCLK to be suitable for CAN_setBitTiming() then yes, that's understood.
The issue here is with the naming of the fields.
I don't agree, it's the values for some of the fields which are incorrect. You could keep the field names the same but just add 1 to some of the values displayed and everything would be fine. For example, if SYSCONFIG displayed the following purple values instead (with code generation unchanged of course), I wouldn't have raised an issue because the value in units of Time Quanta would be correct:
But, as mentioned in the original discussion, this is probably not the best set of fields to present to the SYSCONFG user in auto calculation mode anyway. The TRM CAN section directs the reader to https://www.ti.com/lit/an/sprac35/sprac35.pdf. The associated Excel calculation tool has the following input parameters:
Bit rate (kilobits/sec)
Bus length (m)
Extra propagation delay (us)
CAN clock frequency (MHz)
Why not consider the same input parameters for SYSCONFIG in auto calculation mode? i.e. when "Use Calculated Values..." is selected. Here SYSCONFIG could add real value where the environment of the CAN controller is a factor in the bit timing selection.
Please also consider adding "Sample Point" as a read only field in SYSCONFIG calculated from the inputs.
Thank you.
Kier.
Kier,
it's the values for some of the fields which are incorrect. You could keep the field names the same but just add 1 to some of the values displayed
We are in complete agreement here. What I suggested instead was to rename the fields to "Programmed TSEG1" and "Programmed TSEG2". The alternative is what you suggested and that is arguably better. I will push that change.
Why not consider the same input parameters for SYSCONFIG in auto calculation mode? i.e. when "Use Calculated Values..." is selected. Here SYSCONFIG could add real value where the environment of the CAN controller is a factor in the bit timing selection.
This is an excellent point, thanks for bringing this up. We will review this as a team and get it implemented.
Thanks.