How slow is too slow and timing settings
"Chuck Hackett" <[email protected]>
| Newsgroups | gmane.comp.hardware.bus.can |
|---|---|
| Message-ID | <[email protected]> |
I put a scope on the CAN bus on the bench today and discovered that, due to
a programming error in setting the clock, my CAN bus is running at about 10
kbps rather than 125 kbps. Can this cause problems?, i.e.: Too slow?
I have been reading AN754 (Understanding Microchips CAN Module Bit
Timing) and checking the timing settings I currently have in the code which
I had copied from some example code I found on the Internet some time ago
when I first started with the MCP2515.
The settings are:
BLTMODE = 1
Sample = 1x
SJW = 1 (0 coded in CFG1)
PSEG = 3 (2 coded in CFG2)
SEG1 = 8 (7 coded in CFG2)
SEG2 = 8 (7 coded in CFG3)
In light of comments here and my readings. Im thinking that I need to
change things to:
Given:
Desired bus rate = 61.442kbps
Max bus length = 2,000 feet = ~610m
One-way propagation delay (only cable is significant in my case) =
5ns/m * 610 = 3us
MCP Clock = 1.8432 Mhz
Note: Due to the current PCB design I am restricted to:
MCP Clock = (14.7456Mhz CPU clock) / (2 * (1 + OCR2))
where OCR2 is a control value for Timer-Counter #2 of ATMega1284p
processor)
Using AN754, a spreadsheet and this timing calculator:
http://www.kvaser.com/support/calculators/bit-timing-calculator/
I come up with:
NBT = 16.2760 us
TQ = 1.0851 us
TQs per bit time = 15
PSEG = 5 (actually allows bus up to 1,085 meters)
10 TQ left over for SEG1 & SEG2 allocated as:
PSEG1 = 6
PSEG2 = 4
This results in a sample point of 77.5%
My understanding is that I can use an SJW of 4 which should allow for
maximum clock tolerance.
Misc:
BLTMODE = 1
Sample = 1x
Should I consider 3-point sampling?
Cheers,
Chuck Hackett
"Good judgment comes from experience, experience comes from bad judgment"
7.5" gauge Union Pacific Northern (4-8-4) 844
http://www.whitetrout.net/Chuck
--
Archives and useful links: http://groups.yahoo.com/group/CANbus
Subscribe and unsubscribe at www.vector.com/canlist/
Report any problems to <[email protected]>