PDA

View Full Version : CAN Bus Speed Adjustment


gordym
02-09-07, 12:55 PM
I am connecting an ISOPOD V2 to an existing Can Bus. The Bus currently runs at 83.333Kbps what are the settings I need to use to make the Isopod compatible with this bus speed?

Thanks in Advance
Gordy

gordym
02-19-07, 01:38 PM
Can anyone tell me how to figure this out?

Thanks

Dave
02-20-07, 10:57 AM
There is some information about CAN timings in the DSP56F80x User Manual (http://www.freescale.com/files/dsp/doc/user_guide/DSP56F801-7UM.pdf) linked on the Download page (http://www.newmicros.com/store/product_details/download.html) .

Chapter 8 gives an overview, and states that the CAN_BASE address for the DSP56F805 processor used on the IsoPod is at Hex D80. It appears the registers to be concerned with are CANCTL0, CANCTL1, CANBTR0, and CANBTR1 at base_address + $0, $1, $2, and $3. On bootup of an IsoPod it appears that $0001 is in the base address of D80 for the CAN control register CANCTL0, which means the device is in "soft reset" which allows the other registers to be set. They all appear at $0000 initially. It is recommended in the manual that the CANCTL1 register be set in bit 1 for the clock source to be the IPBus clock, and is also where CAN is enabled in bit 7. So for address D81 for the CANCTL1 should be set to $0081 by using :

HEX
81 D81 ! ( use IPBus clock of 40 Mhz

CAN could instead be set to the external 8 Mhz crystal speed by using :

HEX
80 D81 ! ( use crystal speed of 8 Mhz

Next appears the timing registers CANBTR0 and CANBTR1. In reading through these, the setting information appears to be added in different parts of the chapter, so I'll just go with estimates of what appears workable. For the Sync jump bits can be set to any needed to maintain communications, so 00 to 11 can be used for bits 7, 6. The prescaler has the next 6 bits, which it adds 1 to the value stored, then combined with some additional bits in CANBTR1 determine the speed of communications. There is a formula listed on page 237 that says the Bit Time equals the Precaler divided by the frequency of the CANCLK (determined in the CANCTL1 register above) times a number of Time Quanta to be determined in CANBTR1 register. Rearranging this gives Bit Time times frequency of CANCLK = the Prescaler times the Time quanta. The known is the Bit Time from the required CAN freqency of 83.333 kHz given, which gives a bit time of 12 microseconds. This bit time multiplied by the frequency loaded above of 40 Mhz gives the number 480. This is what the combination of prescaler and time quanta must multiply to. Time quanta are determined in 3 parts on page 220, first a SYNC_SEG always of 1 Time quanta, then a Time segment 1 TSEG1 of 4 to 16 Time quanta, and Time segment 2 TSEG2 of 2 to 8 Time quanta. In an example the chapter recommends a value of 3 for TSEG2, and 4 for TSEG1, and since 83.3 kHz is a lower data rate, the Sampling bit can be set for 3 samples per bit as well. So for the CANBTR1 register we can use 1 in bit 7, 010 in bits 6-4, and 0011 in bits 3-0. This would give a total of 8 time quanta to work with ( 1 SYNC_SEG plus 4 TSEG1 plus 3 TSEG2) that can be multiplied by a prescalar of 60 to get to the required 480 number determined above. So to load 60 in the prescalar use :

HEX
3B D82 ! ( no sync jump width, 59 decimal plus 1 prescale

The sync jump width bits could be modified from the 0 above to 01 or 10 or 11, to change 3B above to 7B, BB, or FB to allow for any clock irregularities.
And to load the other bits for Time segments determined above use :

HEX
A3 D83 ! ( Sample 3x, 3 tq for TSEG2, 4 tq for TSEG1


If the external clock crystal was used by setting the CANCTL1 register to 80, for an 8 Mhz timing speed, then the total from the formula would be 96. If we leave the TSEG bits alone, that would change the prescaler to 12 instead of 60, so the value loaded into D82 would be :

HEX
B D82 ! ( no sync jump width, 11 decimal plus 1 prescale

which could change as previously shown for the sync jump width bits to 4B, 8B, or CB.

Note the use of HEX above is to ensure that the hexadecimal base is used. Only one command of base change is needed after Pod reset.

Compare these possible settings to those in the working CAN example (http://www.newmicros.com/isopod/appnotes/CAN.txt) shown on the Download page.

gordym
02-21-07, 02:00 PM
Thansk for your help on that. I appreciate it.

Gordy