Hi all. Total newb here, sorry. I have an sk-512-b starter kit and trying to get the CAN set up. Running the demo program that sends CAN traffic from CAN0 to CAN4, it works. However, I want it to run at baud 500k so I can have it talk to my existing CAN devices. I know it has something to do with CANBTR0-1 but not sure how to set it for 500k. Does anyone know the correct values for this board and this baud? Thanks!!!
Charlie
解決済! 解決策の投稿を見る。
I think the board you are writing about is ZK-S12-B which contains CAN0 and CAN4 connected to the CAN transceivers MC33388.
The necessary parameters for calculation are described in the AN1798 - CAN Bit Timing Requirements.
(http://www.freescale.com/files/microcontrollers/doc/app_note/AN1798.pdf)
In order to provide some data I'll suppose some input parameters. If you use other parameters, transceiver,… do not hesitate to reply.
I'll suppose you use oscillator clock 16 MHz as a source clock for the CAN modules.
The Physical Interface MC33388D has Tx+Rx prop. delay = 1000 ns and it is designed for communication speed up to 125 kbaud.
INPUTS
fosc = 16 [MHz]
required can speed : fNBT = 125000 [bit/s]
bus propagation delay = 5 [ns/m]
bus length = 0,5 [m]
entire bus propagation delay = 2,5 [ns]
Physical Interface Tx+ Rx propagation delay 1000 [ns]
Overall Propagation Delay = 2005 [ns]
For these inputs and 125kbps bitrate the setup is:
CANBTR0 = 0xC7
CANBTR1 (3 sample per bit) = 0xD8
required oscillator tolerance [%] = 1.21%
However, I have some suggestion how to use the communication between CAN0 and CAN4 without usage of transceivers just by means of direct connection between MCU's CAN Rx,Tx pins. Plese look at CAN without Transceiver-siemens_AP2921, figure 2 (http://www.mikrocontroller.net/attachment/28831/siemens_AP2921.pdf)
For such a connection you can use following setup:
INPUTS
fosc = 16 [MHz]
required can speed : fNBT = 500000 [bit/s]
bus propagation delay = 5 [ns/m]
bus length = 0,5 [m]
entire bus propagation delay = 2,5 [ns]
Physical Interface Tx+ Rx propagation delay 150 [ns]
Overall Propagation Delay = 305 [ns]
CANBTR0 = 0xC1
CANBTR1 (3 sample per bit) = 0xE7
required oscillator tolerance [%] = 1.25%
Moreover, if I am wrong and your board contains some interface which is able o work up to 1Mbit then such interfaces have propagation delay approximately 150~250 ns.
Some calculations for the same setup and different RxTx delays.
fosc = 16 [MHz]
required can speed : fNBT = 500000 [bit/s]
bus propagation delay = 5 [ns/m]
bus length = 0,5 [m]
entire bus propagation delay = 2,5 [ns]
Overall Propagation Delay = 305 [ns]
1) Physical Interface Tx+ Rx propagation delay 150 [ns]
CANBTR0 = 0xC1
CANBTR1 (3 sample per bit) = 0xE7
required oscillator tolerance [%] = 1.25%
2) Physical Interface Tx+ Rx propagation delay 220 ~ 255[ns]
CANBTR0 = 0xC1
CANBTR1 (3 sample per bit) = 0xD8
required oscillator tolerance [%] = 1.219%
3) Physical Interface Tx+ Rx propagation delay 280 [ns]
CANBTR0 = 0xC1
CANBTR1 (3 sample per bit) = 0xC9
required oscillator tolerance [%] = 1.216%
Best regards,
Ladislav
I think the board you are writing about is ZK-S12-B which contains CAN0 and CAN4 connected to the CAN transceivers MC33388.
The necessary parameters for calculation are described in the AN1798 - CAN Bit Timing Requirements.
(http://www.freescale.com/files/microcontrollers/doc/app_note/AN1798.pdf)
In order to provide some data I'll suppose some input parameters. If you use other parameters, transceiver,… do not hesitate to reply.
I'll suppose you use oscillator clock 16 MHz as a source clock for the CAN modules.
The Physical Interface MC33388D has Tx+Rx prop. delay = 1000 ns and it is designed for communication speed up to 125 kbaud.
INPUTS
fosc = 16 [MHz]
required can speed : fNBT = 125000 [bit/s]
bus propagation delay = 5 [ns/m]
bus length = 0,5 [m]
entire bus propagation delay = 2,5 [ns]
Physical Interface Tx+ Rx propagation delay 1000 [ns]
Overall Propagation Delay = 2005 [ns]
For these inputs and 125kbps bitrate the setup is:
CANBTR0 = 0xC7
CANBTR1 (3 sample per bit) = 0xD8
required oscillator tolerance [%] = 1.21%
However, I have some suggestion how to use the communication between CAN0 and CAN4 without usage of transceivers just by means of direct connection between MCU's CAN Rx,Tx pins. Plese look at CAN without Transceiver-siemens_AP2921, figure 2 (http://www.mikrocontroller.net/attachment/28831/siemens_AP2921.pdf)
For such a connection you can use following setup:
INPUTS
fosc = 16 [MHz]
required can speed : fNBT = 500000 [bit/s]
bus propagation delay = 5 [ns/m]
bus length = 0,5 [m]
entire bus propagation delay = 2,5 [ns]
Physical Interface Tx+ Rx propagation delay 150 [ns]
Overall Propagation Delay = 305 [ns]
CANBTR0 = 0xC1
CANBTR1 (3 sample per bit) = 0xE7
required oscillator tolerance [%] = 1.25%
Moreover, if I am wrong and your board contains some interface which is able o work up to 1Mbit then such interfaces have propagation delay approximately 150~250 ns.
Some calculations for the same setup and different RxTx delays.
fosc = 16 [MHz]
required can speed : fNBT = 500000 [bit/s]
bus propagation delay = 5 [ns/m]
bus length = 0,5 [m]
entire bus propagation delay = 2,5 [ns]
Overall Propagation Delay = 305 [ns]
1) Physical Interface Tx+ Rx propagation delay 150 [ns]
CANBTR0 = 0xC1
CANBTR1 (3 sample per bit) = 0xE7
required oscillator tolerance [%] = 1.25%
2) Physical Interface Tx+ Rx propagation delay 220 ~ 255[ns]
CANBTR0 = 0xC1
CANBTR1 (3 sample per bit) = 0xD8
required oscillator tolerance [%] = 1.219%
3) Physical Interface Tx+ Rx propagation delay 280 [ns]
CANBTR0 = 0xC1
CANBTR1 (3 sample per bit) = 0xC9
required oscillator tolerance [%] = 1.216%
Best regards,
Ladislav
Thanks, I'll give it a try!
Charlie