Hi Allen
Thanks for your reply but I am bit confused about formula. In the manual the formula mentioned;
TSeg1 = (TSEG1 + 1)*tq
TSeg2 = (TSEG2 + 1)*tq
Where tq = (BRP+1)/fCAN
so
tq = (15+1) /40000000
tq =
0.0000004
TSeg1 = (4+1)*tq
TSeg2 = (3+1)*tq
Substituting, I get
Baudrate = 40,000,000 / ((15 + 1) * (1 + (9*tq)))
= 40,000,000 / (16 *
1.0000036)
= 40,000,000 /
16.0000576
=
2499991
Finally the Baudrate is 2499K. Please clarify me where I went wrong.
Personally I am not interested in code generators but since I am new to CAN how do I verify my configurations. Is there any way to verify my register settings
other than DAvE? Please let me know.
Regards,
From: canlist-owner@...
[mailto:canlist-owner@...] On Behalf Of
Allen Pothoof
Sent: Thursday, June 25, 2009 11:04 PM
To: canlist@...
Subject: RE: [CANLIST] Reg CAN Baud Rate Config
My first thought is that you either hit a typo during the calculation or bounced a "9" during the e-mail; after all, 249,991 is
reasonably close to 250,000 and the numbers sometimes aren't exact. But, in digging into this, I don't see an issue and I can't duplicate your numbers.
WARNING: I have never worked with DAvE (and have both a personal and professional dislike for code generators/wizards; YMMV) and I've never worked with the xc164 but I have worked with the C167 and I can read user's manuals.
Based on the TwinCAN User's Manual, your interpretations of BRP and TSEG1/2 are correct. Further, I see from the manual that
TSeg1 = (TSEG1 + 1)
TSeg2 = (TSEG2 + 1)
So, I apply the calculation for BaudRate:
Baudrate =
fCAN / ((BRP + 1) *
(1 + TSeg1 + TSeg2))
Substituting, I get
Baudrate = 40,000,000 / ((15 + 1) * (1 + 4 + 1 + 3 + 1))
= 40,000,000 / (16 * 10)
= 40,000,000 / 160
= 250,000
Dead on.
If I try to back-calculate the bit timing:
2499991 = 40,000,000 / X
I get X = 16.00005760...
I still think you slipped a decimal somewhere (probably on that 40Mhz but maybe not) but even allowing for that, you're off and this calculation is straight-forward enough that you shouldn't have to worry about truncation or rounding errors.
So, the numbers you are working with look right and I can't tell you where the calculation went awry.
Regards,
Allen Pothoof
From: manivannan.d@...
To:
Date: Wed, 24 Jun 2009 10:25:50 +0530
Subject: [CANLIST] Reg CAN Baud Rate Config
Hi All,
I am in initial phase of CAN Initialization. I have configure to my CAN Baud rate for 250Kbaud, I referred infineon DAvE setting, the preferred values
are BRP = 15, TSEG1 = 4, TSEG2 = 3 (CAN_ABTRL = 0x344F). If I apply these values to the baud rate formula I am getting the value of 2499991.
I am using Infineon xc164cs. Clock is 40MHz to Twin CAN module. If any using this micro let me know where I am wrong.
Regards,
UCAL Fuel Systems Limited
Tel: +91 44 42081491 Ext: 106
This email (including any attachments) is intended for the sole use of the intended Recipient/s and contains
material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION and is protected by law. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended
recipient, please contact the sender by email and delete all copies, promptly and permanently. UCAL Fuel Systems reserves the right to monitor record and inspect all email communications through its networks. Your messages shall be subject to such lawful supervision
as deemed fit by UCAL Fuel Systems in order to protect its information, interests and reputation
Windows Live™: Keep your life in sync.
Check it out.
This email (including any attachments) is intended for the sole use of the intended Recipient/s and contains material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION and is protected by law. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies, promptly and permanently. UCAL Fuel Systems reserves the right to monitor record and inspect all email communications through its networks. Your messages shall be subject to such lawful supervision as deemed fit by UCAL Fuel Systems in order to protect its information, interests and reputation