AP29000
Connecting C166 and C500 Microcontroller to CAN
Ways of handling the SAE 81C90/91 and the CAN Module on the C167CR / C515C
Application Note
57
V 1.0, 2004-02
If a
Data Frame
is received in a receive object (DIR=0) and NEWDAT=0 in the
corresponding Message Control Register, the CAN controller sets NEWDAT and the
data in the Data Field is written into the data bytes of the corresponding receive
object. Additionally, the Arbitration Registers and the data length code of the receive
object are updated with the identifier and the data length code of the received Data
Frame. If RXIE in the corresponding Message Control Register and the global
Interrupt Enable bit (bit IE in the Control Register) is set, the CAN controller sets
INTPND (INterrupt PeNDing) in the Message Control Register which generates an
receive interrupt to the CPU.
In the C167CR, CAN interrupts are controlled via the corresponding Interrupt
Control Register XP0IC. In the C515C, CAN interrupts can be activated /
deactivated via the bit ECAN of the Special Function Register IEN2.
•
In the interrupt service routine, the reason for the interrupt (status change interrupt
or interrupt of one of the message objects) can be read from the contents of the
Interrupt Register (the so-called INTID (=INTerrupt IDentifier)). If bit SIE in the
Control Register has been set and the CAN controller updated (not necessarily
changed) the Status Register (which it always does on transmission or reception of
a frame), INTID will have the value "01". If a message has been received, RXOK is
set, if a message has been successfully transmitted, TXOK is set. Read the Status
Register to service the status change interrupt and to update INTID. If a message
was received by message object "n", INTID will then have the value "n+2".
After now the message object that has caused the interrupt has been identified, the
data bytes of the message objects can be read and evaluated. Then INTPND and
NEWDAT in the corresponding Message Control Register can be reset:
C167CR:
MCR_Mn = 0xFDFD;
/* reset INTPND,NEWDAT of obj. n */
C515C:
MCR0_Mn = 0xFD;
/* reset INTPND,NEWDAT of obj. n */
MCR1_Mn = 0xFD
/* RMTPND = unchanged; TXRQ = set */
/* MSGLST = unchanged; NEWDAT = reset */
/* MSGVAL = unchanged; TXIE = unchanged */
/* RXIE = unchanged; INTPND = reset */