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
61
V 1.0, 2004-02
•
Please note that after a Remote Frame has been sent out (RTR=1), the
corresponding Data Frame is not stored in the same message object. The
SAE 81C90/91 could be used as follows:
•
One message object is used for the transmission of Data Frames (RTR=0; e.g. MO
1), whose identifier and DLC is always configured new before each transmission.
•
One message object is used for the transmission of Remote Frames (RTR=1,
DLC=0; e.g. MO 2), whose identifier is always configured new before each
transmission.
•
Some other message objects are used for the reception of Data Frames (certain
identifier, certain DLC; RTR=0). In these message objects, also the Data Frames
that correspond to Remote Frames sent by MO 1 are received. This corresponds to
a receive object in the CAN module of the C167CR / C515C (without the possibility
of sending its own Remote Frames, though).
•
The remaining message objects are used for the automatic answering of incoming
Remote Frames (certain identifier, certain DLC; RTR=1). This corresponds to a
transmit object in the CAN module of the C167CR / C515C (without the possibility of
sending its own Data Frames, though).
/* load descriptor bytes of MO n */
/* Example: Identifier 1001 0110 000, RTR = 0, DLC = 8 */
DRnH
=
0x96;
/* load descriptor high byte object n */
DRnL
=
0x08;
/* load descriptor low byte object n */
/*Byte H> 1 0 0 1 0 1 1 0 | 0 0 0 0 1 0 0 0 <Byte L */
/* |<- IDENTIFIER ->|RTR|<-DLC->| */
•
The descriptor bytes that are not going to be used should be configured with an
unused identifier (as there's no way to completely disable a message object). Not
initialized descriptor bytes have unknown values after reset and can lead to
unexpected behavior. The data bytes can be cleared to 00h. Please note that writing
to the data bytes must always start with one of the data bytes 7 to 1 and
must end
with writing of data byte 0
, because on writing of data byte 0, the contents of the the
shadow register is transferred in parallel into the RAM of the respective message.
Please also take care that a read operation to the data bytes of a message object
must not be interrupted by a write operation and vice versa. This ensures that the
SAE 81C90/91 always works on consistent data.
/* invalidate unused descriptor bytes: */
DRmH = DRmL = 0x..;
/* unused identifier */
...
/* clear corresponding data bytes: */
BYTE7MSGm = 0x00;