AN2320 Freescale Semiconductor / Motorola, AN2320 Datasheet - Page 18

no-image

AN2320

Manufacturer Part Number
AN2320
Description
Interfacing the MCF5272 to a Standalone CAN Controller
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
CAN Transmit and Receive
The CAN bit time, therefore, equates to
period of the bit time quantum.
The TSEG1, SJW, and TSEG2 fields in the bit timing register are used to define the different segments and
BRP and DIV8 set the time quantum period as follows:
T
T
T
For the register settings in the example code below, TSEG1 = 6, TSEG2 = 7, SJW = 0, BRP = 2. This results
in a CAN bit time of 2us or a baud rate of 0.5Mbit/s. No baud rate prescaler is used; therefore, DIV8 is
ignored in these calculations.
Initialisation code for both nodes is almost identical, the only difference being the initialisation of the CAN
node B interrupt mask register to generate an interrupt when a message is received. Message object 0 is
assigned to CAN node A and message object 1 is assigned to CAN node B. The initialisation code is shown
for CAN node B.
/*Node
QSPI_SendByte(CAN_BCR, 0x41);
/*Bit timing register : set for 500 kbit/s : ((0+1)+(6+1)+(7+1))* 0.125us)*/
QSPI_SendByte(CAN_BBTR, 0x02);
QSPI_SendByte(CAN_BBTR+1, 0x67);
/*Enable msg obj 1 to be considered as interrupt source*/
QSPI_SendByte(CAN_BIMR0, 0x02);
/*synchronise CAN node to bus and enable*/
QSPI_SendByte(CAN_BCR, 0x00);
3.4
In the CAN application example code, CAN node A is used to transmit data on the CAN bus and CAN node
B is used to receive data. When data is received, an interrupt is generated, the data is retrieved, and new data
is transmitted.
To receive and transmit data, each node must be assigned a message object. This message object must be
configured using the message object control, configuration, arbitration, and data registers. The message
object control register is used to enable interrupts on transmitting or receiving a message, to tag a message
18
t
quantum
sync
prop
buff2
= SJW + 1
+ T
= TSEG2 + 1
=
buff
BRP
-------------------- -
CAN Transmit and Receive
control
f
= TSEG1 + 1
CAN
+
1
Interfacing the MCF5272 to a Standalone CAN Controller
register
Tsync
Freescale Semiconductor, Inc.
For More Information On This Product,
Figure 9. CAN Bit Time Segments
:
Go to: www.freescale.com
Tprop
reset
(
T
CAN bit time
sync
T
interrupts,
prop
Tbuff1
T
buff
Sample
1
T
buff
stop
Tbuff2
2
)
t
quantum
Transmit
CAN
where t
to
initialise*/
quantum
MOTOROLA
is the

Related parts for AN2320