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
66
V 1.0, 2004-02
2.
The CAN controller then sets
•
INTPND and NEWDAT
(if MO 15 is configured to receive Data Frames (DIR = 0)) or
•
INTPND and RMTPND
(if MO 15 is configured to receive Remote Frames (DIR = 1))
in MO 15 and bit RXOK in the Control Register.
3.
An interrupt is generated to the CPU. Now the CPU can read the interrupt register
and will detect "02" (message 15 Interrupt).
4.
Now the CPU can read (and store elsewhere if necessary)
•
the identifier of the received frame (via access to the Arbitration Registers),
•
additionally the new data bytes (if a Data Frame was received and the identifier tells
the CPU that the received data has to be evaluated).
and then reset in MO 15 (the momentarily accessed buffer):
•
INTPND and NEWDAT (if a Data Frame was received)
•
INTPND, NEWDAT and RMTPND (if a Remote Frame was received).
This will release the momentarily accessed buffer.
5.
The CPU now has to check INTID in the interrupt register again.
•
If INTID is no longer "02" but has been updated by the CAN controller to "00" or an
other value, both buffers of MO 15 are released.
•
If INTID is still "02", then the other buffer of MO15 is still allocated. The CPU then
has to continue with step 4, then automatically accessing the other (still allocated)
buffer.
6.
Steps 4 and 5 are to be repeated until both buffers are released.
7.
If both buffers of MO 15 are released and no other interrupt is pending, INTID
should then have the value 00h. The interrupt service routine can be left.
Otherwise (if INTID <> 0), the pending interrupt sources have to be serviced until
INTID is 00h.
8.
If a Remote Frame was received and is to be answered by this node, this can be
done by loading a transmit object with the identifier of the received Remote Frame
and the requested data. Then this object must be transmitted.