What is the CAN bit rate used in AN11238

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

What is the CAN bit rate used in AN11238

736 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rbeck on Wed Mar 18 12:54:28 MST 2015
I am trying to do the demo from AN11238
I have two boards connected, the boards talk to each other, and they work fine (I can push buttons and the leds change)
however I can not get the bus analyzer to see any packets
when you open the PCAN-view software it asks for the bit rate, and I do not know what bit rate is used
I have searched for the word "rate" in all the documents, code, and forms, but nothing

so I need to know the bit rate used by the demo in AN11238
has anyone else run this demo?
Labels (1)
0 Kudos
Reply
6 Replies

668 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed Apr 08 06:38:35 MST 2015

Quote: superkato
Its very hard to understand.

baudrateCalculate(500000, CanApiClkInitTable); //500kbits

LPC_CCAN_API->init_can(&CanApiClkInitTable[0], TRUE);




What's hard to understand there  :quest:

You are using a function which is doing the calculation for you 
0 Kudos
Reply

668 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by superkato on Wed Apr 08 05:38:06 MST 2015
Its very hard to understand.

My Clock is 48mhz, the external crystal has 12Mhz
20 nodes
6 bytes of data
cable length up to 10meters

baudrateCalculate(500000, CanApiClkInitTable); //500kbits

LPC_CCAN_API->init_can(&CanApiClkInitTable[0], TRUE);



void baudrateCalculate(uint32_t baud_rate, uint32_t *can_api_timing_cfg)
{
uint32_t pClk, div, quanta, segs, seg1, seg2, clk_per_bit, can_sjw;
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_CAN);
pClk = Chip_Clock_GetMainClockRate();

clk_per_bit = pClk / baud_rate;

for (div = 0; div <= 15; div++) {
for (quanta = 1; quanta <= 32; quanta++) {
for (segs = 3; segs <= 17; segs++) {
if (clk_per_bit == (segs * quanta * (div + 1))) {
segs -= 3;
seg1 = segs / 2;
seg2 = segs - seg1;
can_sjw = seg1 > 3 ? 3 : seg1;
can_api_timing_cfg[0] = div;
can_api_timing_cfg[1] =
((quanta - 1) & 0x3F) | (can_sjw & 0x03) << 6 | (seg1 & 0x0F) << 8 | (seg2 & 0x07) << 12;
return;
}
}
}
}
}

0 Kudos
Reply

668 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue Apr 07 14:13:31 MST 2015

Quote: superkato
how can I change that to 500kbits?  Could you please tell me the correct math?



See: http://www.lpcware.com/content/forum/lpc11cxx-can-baud-rate-calculation
0 Kudos
Reply

668 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by superkato on Tue Apr 07 13:26:22 MST 2015
Hi,

how can I change that to 500kbits?  Could you please tell me the correct math?

I have 20 nodes on the bus sending  data with 6bytes by request from a master.

BR
Sven


0 Kudos
Reply

668 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed Mar 18 15:04:20 MST 2015

Quote: rbeck
...so I need to know the bit rate used by the demo in AN11238...




CAN_MSG_OBJ CANopen_Msg_Obj;
uint32_t ClkInitTable[2] = {/* Initialize CAN Controller structure*/
 [color=#30f] 0x00000000[/color]UL,    /* CANCLKDIV */
  0x0000[color=#f00]1C[/color][color=#0f0]57[/color]UL   /* CAN_BTR */
};
 
 
  48E6 / ([color=#30f]0 [/color]+1) / ([color=#0f0]23+1[/color]) / ([color=#f30] 12 + 1[/color] + 3) = 125E3 
0 Kudos
Reply

668 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rbeck on Wed Mar 18 13:14:25 MST 2015
well just in case anyone else needs this
the bit rate is 125k, and the filter set to extended
0 Kudos
Reply