AN2320 Freescale Semiconductor / Motorola, AN2320 Datasheet - Page 20

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
__interrupt__
void ext_irq1_handler (void)
{
printf("ext_irq1_handler\n");
/*Read received data and output over M5272C3 terminal uart*/
/*Set Int1 IPL =6, for /Out1*/
/*Msg obj interrupt pending flag reset*/
/*Reset transmission message object, inhibit transmission*/
/*Alternate message object 0 Tx data*/
if (toggle)
/*Set message object to start transmission*/
CAN_MsgObjTx_Start(Msg0);
}
The functions called by main and by the interrupt service routine have been made as generic as possible
allowing any message object to be assigned to any node, allowing any message object to be configured as
a transmit object or a receive object, allowing any number of bytes for transmission or reception, allowing
the ID of any message to be changed easily, and ensuring interrupts can be enabled or disabled easily.
CAN_MsgObj_Init
message ID. During initialisation and update, the message object must be set to invalid to prevent the CAN
controller from using it. All request flags must be reset, the new data flag must be reset to show no update
of data has occurred yet, and in the case of a transmit message object, automatic transmission must be
disabled. Once the flags are reset, the message object is inoperable and automatic transmission is disabled.
When the message object is configured to receive then the data lost flag must be reset.
void CAN_MsgObj_Init(uint8 Node, uint8 Msg, uint8 TxRx, uint8 NoBytes, uint8 ID, uint32
IDnum)
{
/*Msg obj tagged invalid to allow update*/
QSPI_SendByte(CAN_MSG_CTRL + (Msg*0x20), 0x7F);
20
MCF5272_IMM *imm = mcf5272_get_immp();
CAN_MsgObj_RxData(Msg1,8);
MCF5272_WR_SIM_ICR1(imm,0xE8888888);
CAN_MsgObj_IntReset(Msg1);
CAN_MsgObjTx_Reset(Msg0);
else
{
}
{
}
CAN_MsgObj_TxData(Msg0, 8, 0x55AA55AA, 0x11001100);
toggle = 0;
CAN_MsgObj_TxData(Msg0, 8, 0x11001100, 0x55AA55AA);
toggle = 1;
assigns a message object to a node, defines the number of bytes for transfer, and sets the
Interfacing the MCF5272 to a Standalone CAN Controller
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA

Related parts for AN2320