AN2320 Freescale Semiconductor / Motorola, AN2320 Datasheet - Page 19

no-image

AN2320

Manufacturer Part Number
AN2320
Description
Interfacing the MCF5272 to a Standalone CAN Controller
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Freescale Semiconductor, Inc.
CAN Transmit and Receive
valid or invalid, and to signal the update of a message. The configuration register determines which CAN
node the message object is assigned to, defines the message identifier length and number of data bytes to be
transmitted or received, sets the object for transmit or receive, and selects the interrupt node to use if the
message object is configured to generate an interrupt on transmitting or receivng a message. The data
register is used to store data for transmission or to store any data received. There can be up to 8 data bytes
per CAN message; therefore, each CAN message object has two 32-bit data registers. Finally, the arbitration
register holds the message identifier. For bit-level specific information, refer to the 82C900 user manual,
www.infineon.com/cgi/ecrm.dll/ecrm/scripts/public_download.jsp?oid=16123&parent_oid=16899.
In the example code the message objects are initialised in function main(), following the initialisation of the
QSPI module and the intialisation of the 82C900 CAN controller as detailed above. The function main() is
listed below. Message object 0 is assigned to CAN node A and configured to transmit 8 bytes of data, and
message object 1 is assigned to CAN node B and configured to receive 8 bytes of data. Both message objects
are assigned the same ID so that, when both nodes are connected externally via the transceivers, CAN node
B will receive any data transmitted by CAN node A. In the interrupt service routine, also listed below, the
data received is retrieved and output over the terminal UART on the M5272C3 board. The interrupt is then
reset and new data is transmitted.
void main ()
{
mcf5272_wr_sr (MCF5200_SR_IPL_0);
/*Initialise the QSPI module*/
mcf5272_qspi_init();
/*CAN node A and B initialisation*/
CAN_Node_Init();
/*Assign Msg0 to CAN node A, to transmit 8 bytes of data,
with standard ID of 2*/
CAN_MsgObj_Init(A, Msg0, Tx, 8, Stand, 2);
/*Assign Msg1 to CAN node B, to receive 8 bytes of data, with standard ID of 2*/
CAN_MsgObj_Init(B, Msg1, Rx, 8, Stand, 2);
/*Load Msg0 transmit data*/
CAN_MsgObj_TxData(Msg0, 8, 0xAA55AA55, 0x55AA55AA);
/*Enable Msg1 receive interrupt, assign to interrupt node 1 and /OUT1*/
CAN_MsgObj_IntEnable(Msg1,Rx,1);
/*Enable Msg1 to receive*/
CAN_MsgObjRx_Enable(Msg1);
/*Enable Msg0 to begin transmitting*/
CAN_MsgObjTx_Start(Msg0);
while (1)
;
}
19
Interfacing the MCF5272 to a Standalone CAN Controller
MOTOROLA
For More Information On This Product,
Go to: www.freescale.com

Related parts for AN2320