© 2004 Microchip Technology Inc. DS70070B-page 23-49
Section 23. CAN
CAN Module
23
23.7 Transmission
This subsection describes how the CAN module is used to transmit CAN messages.
23.7.1 Real Time Communication and Transmit Message Buffering
For an application to effectively transmit messages in real-time, the CAN nodes must be able to
dominate and hold the bus, assuming that nodes messages are of a high enough priority to win
arbitration on the bus. If a node only has 1 transmission buffer, it must transmit a message, then
release the bus while the CPU reloads the buffer. If a node has two transmission buffers, one
buffer could be transmitting while the second buffer is being reloaded. However, the CPU would
need to maintain tight tracking of the bus activity to ensure that the second buffer is reloaded
before the first message completes.
Typical applications require three transmit message buffers. With three buffers, one buffer can
be transmitting, the second buffer can be ready to transmit as soon as the first is complete, and
the third can be reloaded by the CPU. This eases the burden of the software to maintain
synchronization with the bus (see Figure 23-12).
Additionally, the three buffers allow some degree of prioritizing of the outgoing messages. For
example, the application software may have a message enqueued in the second buffer while it
is working on the third buffer. The application may require that the message going into the third
buffer is of higher importance than the one already enqueued. If only 2 buffers are available, the
enqueued message would have to be deleted and replaced with the third. The process of
deleting the message may mean losing control of the bus. With 3 buffers, both the second and
the third message can be enqueued, and the module can be instructed that the third message is
higher priority than the second. The third message will be the next one sent followed by the
second.
23.7.2 Transmit Message Buffers
The CAN module has three Transmit Buffers. Each of the three buffers occupies 14 bytes of data.
Eight of the bytes are the maximum 8 bytes of the transmitted message. Five bytes hold the
standard and extended identifiers and other message arbitration information.
The last byte is a control byte associated with each message. The information in this byte
determines the conditions under which the message will be transmitted and indicates status of
the transmission of the message.
The TXnIF bit (CiINTF<2>, CiINTF<3> or CiINTF<4>) will be set and the TXREQ bit
(CiTXnCON<3>) will be clear, indicating that the message buffer has completed a transmission.
The CPU will then load the message buffer with the contents of the message to be sent. At a
minimum, the standard identifier register CiTXnSID must be loaded. If data bytes are present in
the message, the TXBnDm registers are loaded. If the message is to use extended identifiers,
the CiTXnEID register and the EID<5:0> bits (CiTXnDLC<15:10>) are loaded and the TXIDE bit
is set (CiTXnSID<0>).
Prior to sending the message, the user must initialize the TXnIE bit (CiINTE<2>, CiINTE<3> or
CiINTE<4>) to enable or disable an interrupt when the message is sent. The user must also
initialize the transmit priority. Figure 23-12 shows a block diagram of the Transmit Buffers.