123
www.national.com
CP3
BT26
CNSTAT status section will be 0101b, as the buffer was
RX_FULL (0100b) before. After finally reading the last re-
ceived message, the CPU can reset the buffer to
RX_READY.
19.6
TRANSMIT STRUCTURE
To transmit a CAN message, software must configure the
message buffer by changing the buffer status to
TX_NOT_ACTIVE. The buffer is configured for transmission
if the ST[3] bit of the buffer status code (CNSTAT) is set. In
TX_NOT_ACTIVE status, the buffer is ready to receive data
from the CPU. After receiving all transmission data (ID, data
bytes, DLC, and PRI), the CPU can start the transmission
by writing TX_ONCE into the buffer status register. During
the transmission, the status of the buffer is TX_BUSYx. Af-
ter successful transmission, the CAN module will reset the
buffer status to TX_NOT_ACTIVE. If the transmission pro-
cess fails, the buffer condition will remain TX_BUSYx for re-
transmission until the frame was successfully transmitted or
the CPU has canceled the transmission request.
To Send a Remote Frame (Remote Transmission Request)
to other CAN nodes, software sets the RTR bit of the mes-
sage identifier (see Storage of Remote Messages on page
132) and changes the status of the message buffer to
TX_ONCE. After this remote frame has been transmitted
successfully, this message buffer will automatically enter
the RX_READY state and is ready to receive the appropri-
ate answer. Note that the mask bits RTR/XRTR need to be
set to receive a data frame (RTR = 0) in a buffer which was
configured to transmit a remote frame (RTR = 1).
To answer Remote Frames, the CPU writes TX_RTR in the
buffer status register, which causes the buffer to wait for a
remote frame. When a remote frame passes the accep-
tance filtering mask of one or more buffers, the buffer status
will change to TX_ONCE_RTR, the contents of the buffer
will be transmitted, and afterwards the CAN module will
write TX_RTR in the status code register again.
If the CPU writes TX_ONCE_RTR into the buffer status, the
contents of the buffer will be transmitted, and the successful
transmission the buffer goes into the “wait for Remote
Frame” condition TX_RTR.
19.6.1
Transmit Scheduling
After writing TX_ONCE into the buffer status, the transmis-
sion process begins and the BUSY bit is set. As soon as a
buffer gets the TX_BUSY status, the buffer is no longer ac-
cessible by the CPU except for the ST[3:1] bits of the CN-
STAT register. Starting with the beginning of the CRC field
of the current frame, the CAN module looks for another buff-
er transmit request and selects the buffer with the highest
priority for the next transmission by changing the buffer
state from TX_ONCE to TX_BUSY. This transmit request
can be canceled by the CPU or can be overwritten by anoth-
er transmit request of a buffer with a higher priority as long
as the transmission of the next frame has not yet started.
This means that between the beginning of the CRC field of
the current frame and the transmission start of the next
frame, two buffers, the current buffer and the buffer sched-
uled for the next transmission, are in the BUSY status. To
cancel the transmit request of the next frame, the CPU must
change the buffer state to TX_NOT_ACTIVE. When the
transmit request has been overwritten by another request of
a higher priority buffer, the CAN module changes the buffer
state from TX_BUSY to TX_ONCE. Therefore, the transmit
request remains pending. Figure 56 further illustrates the
transmit timing.
Figure 56.
Data Transmission
If the transmit process fails or the arbitration is lost, the
transmission process will be stopped and will continue after
the interrupting reception or the error signaling has finished
(see Figure 56). In that case, a new buffer select follows and
the TX process is executed again.
Note:
The canceled message can be delayed by a TX re-
quest of a buffer with a higher priority. While TX_BUSY is
high, software cannot change the contents of the message
buffer object. In all cases, writing to the BUSY bit will be ig-
nored.
19.6.2
Transmit Priority
The CAN module is able to generate a stream of scheduled
messages without releasing the bus between two messag-
es so that an optimized performance can be achieved. It will
arbitrate for the bus immediately after sending the previous
message and will only release the bus due to a lost arbitra-
tion.
If more than one buffer is scheduled for transmission, the
priority is built by the message buffer number and the prior-
ity code in the CNSTAT register. The 8-bit value of the prior-
SOF
1 BIT
IFS
3 BIT
EOF
7 BIT
TX_BUSY
current buffer
CPU write TX_ONCE
in buffer status
Begin selection of next buffer
if new tx_request
TX_BUSY
next buffer
BUS
IDLE
ACK
FIELD
2 BIT
CRC
FIELD
16 BIT
DATA FIELD
(IF PRESENT)
n × 8 BIT
ARBITRATION FIELD
+
CONTROL
12/29 BIT
+
6 BIT
BUS
DS040