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
56
V 1.0, 2004-02
•
Then the node which is supposed to provide the requested data will receive the
Remote Frame and answer it with the corresponding Data Frame. If this Data Frame
is received, the CAN controller sets NEWDAT in the Message Control Register. So
the CPU could poll NEWDAT to wait for this event:
C167CR:
while ((MCR_Mn & 0x0200) == 0);
C515C:
while ((MCR1_Mn & 0x02) == 0);
/* wait until Data Frame arrives (until NEWDAT = 1) */
Another possibility is to react on the receive interrupt or the status change interrupt of
the CAN controller which are generated on the reception of the Data Frame (if enabled
in the Control Register (IE=1; SIE=1) or in the Message Control Register (RXIE=set)
resp.).
•
Now the requested data can be read from the data bytes of the message object.
•
NEWDAT should then be reset:
C167CR:
MCR_Mn = 0xFDFF;
/* reset NEWDAT */
C515C:
MCR1_Mn = 0xFD;
/* reset NEWDAT */
/* RMTPND = unchanged; TXRQ = unchanged */
/* MSGLST = unchanged; NEWDAT = reset */
/* MSGVAL = unchanged; TXIE = unchanged */
/* RXIE = unchanged; INTPND = unchanged */
6.4.4
Evaluation of a received Message with the CAN Module
•
If the C167CR or the C515C receive a message with a matching identifier this can
either be a data or a Remote Frame.
If a
Remote Frame
is received in one of the message objects 1-14 configured as
transmit object (DIR=1), only the data length code is stored in the corresponding
object. The identifier and the data bytes remain unchanged. The CAN controller sets
TXRQ and RMTPND in the corresponding Message Control Register. The set
TXRQ bit field will cause the Remote Frame to be immediately and automatically
answered by the CAN controller with the corresponding Data Frame (if the CPUUPD
field is not set!). If RXIE in the Message Control Register and the global Interrupt
Enable bit (bit IE in the Control Register) is set, the CAN controller also sets
INTPND (INterrupt PeNDing) in the Message Control Register which generates an
receive interrupt to the CPU