Can't start CAN link between to nodes

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can't start CAN link between to nodes

1,382 Views
sauliuz
Contributor I
Hello,

I am trying to start CAN communications on MC9S12C32. I am using AN3034 application notes and code example that goes with it. I tested the Back Loop mode, which is implemented in the example and it seems to work well. Now I am trying to set up a link between mentioned controller and GZ16 STK. It is a 68HC908GZ16 controller starter kit, which has CAN. I trust the code (originally shipped with) that runs this GZ16 so I believe that this node is properly configured and has CAN communication set for 50kBaud (the width of a bit on the oscilloscope on the bus wire is approx. 20us, the rear edge (left) of the bit is bended significantly). The board is controlled through SPI.

Sample code is set for 125kbps speed it says in the AN3034. According to the data sheet:
Bit time = ((Prescaller Value)*(1+TimeSeg1+TimeSeg2))/fCANCLK

My MSCAN Clock Source is 16 MHz oscillator clock (CANCTL1 = 0x80) just like in AN3034. I want speed 50 kbps so I pick up coefficients:

TimeSeg1 = 11 (TSEG1 = 0b1010)
TimeSeg2 = 4 (TSEG2 = 0b011)
PrescallerValue = 20 (P=0b10101)
SyncJump = 3 (SJW = 0b10)
so: CANBTR0 = 0x95; CANBTR1 = 0x3A;

According to formula I should get 20us time witch is what I see when message comes from the GZ16 node. But in practice I see something like 22us. Significantly bended left edge of the bit as well. The hardware seems to be right done (I use SN65HVD251 as a CAN transceiver). Hence microcontroller hangs when I try to send a message through CAN because it does no receive any acknowledgment. What do I do wrong????

Please, help.

Saulius
Labels (1)
0 Kudos
Reply
1 Reply

549 Views
kef
Specialist I
You wrote:
  PrescallerValue = 20 (P=0b10101)
 
0b10101 is 21 and PrescalerValue=22

 
0 Kudos
Reply