Overwrite enable/disable feature – Maxim Integrated High-Speed Microcontroller Users Guide: Network Microcontroller Supplement User Manual

Page 158

Advertising
background image

High-Speed Microcontroller User’s

Guide: Network Microcontroller

Supplement

158

Remote Frame Handling in Relation to the DTBYC Bits

The DTBYC bits function slightly differently when remote frames are used. The data length code currently programmed in the message

center is overwritten by the data length code field of the incoming remote request frame so that the requested number of data bytes

can be sent in response to the remote request. The following example demonstrates how the DTBYC bits are modified by a received

remote frame request.

1.

Assume the microcontroller has programmed the following into a message center:

DTBYC = 5, data field = 75 AF 43 2E 12 78 90 00

Note: Only the first through the fifth data bytes are recognized because DTBYC = 5.

2.

When the CAN module successfully receives a remote frame with the following data:

Identifier = ID, DTBYC = 2, RTR = 1.

3.

The incoming message overwrites the identifier and the data length code. The new data in the message center is:

DTBYC = 2, data field = 75 AF 43 2E 12 78 90 00

Note: Only the first and second data bytes are recognized because DTBYC is now 2.

4.

The outgoing response is a data frame containing the following information:

DTBYC = 2, data field = 75 AF

Important Information Concerning ID Changes when Awaiting Data from a Previous Remote
Frame Request

The use of acceptance filtering (MEME = 1) in conjunction with remote frame requests can result in a modification of the message cen-

ter arbitration registers. Suppose that, for example, a message center is configured to transmit a remote frame request (MTRQ = 1,

EXTRQ = 0, T/R = 0, and MSRDY = 1). If arbitration masks are used, it is possible for a second frame request from an external node

to modify this requesting node’s arbitration register value prior to reception of the previously requested data. When a remote frame

request is received, the message ID is loaded into that message center’s arbitration registers. When message identification masking

is not used (MEME = 0), the message ID always matches the arbitration value, so the process is transparent. If masking is used, how-

ever, the message ID ANDed with the appropriate mask is loaded into that message center’s arbitration registers, resulting in a change

of the arbitration values for that message center. To prevent this situation, acceptance filtering should be disabled (MEME = 0) for any

message center configured for remote frame handling.

Overwrite Enable/Disable Feature

The write-over enable bit (WTOE) located in each message center (C0MxAR3.0) enables or disables the overwriting of unread mes-

sages in message centers 1–15. Programming WTOE = 1 following a system reset or CRST bit-enabled reset allows newly received

messages that pass arbitration to overwrite unread (i.e., message centers with DTUP = 1) messages. When an overwrite occurs, the

receive overwrite (ROW) bit in the respective CAN message control register is set. When WTOE = 0, message centers that have data

waiting to be read (indicated by DTUP = 1) or transmitted (EXTRQ = 1) are not overwritten by incoming data.

Special care must be taken when reading data from a message center with the overwrite feature enabled (WTOE = 1). Caution is need-

ed because the WTOE bit, when set, allows an incoming message to overwrite the message center. If an overwrite occurs at the same

time that software is attempting to read several bytes from the message center (such as a multi-byte data field), it is possible that the

read could return a mix of information from the old and overwriting messages. If the message center being set up with WTOE = 1 was

previously a transmit message center, ensure that the TIH bit is cleared to 0 (TIH can only be written while T/R is set to 1). If TIH is set

to 1 and that message center is changed to receive with WTOE = 1, the ROW bit will always read back a 1, even though a receive

overwrite condition may not have occurred. To avoid this situation, software should clear the DTUP bit to 0 prior to reading the mes-

sage center, and then verify afterwards that the DTUP bit remained at 0. If DTUP remains cleared after the read, no overwrite occurred

and the returned data was correct. If DTUP = 1 after the read, software should again clear DTUP = 0 and reread the message center,

since a possible overwrite has occurred. The original message is lost (as planned since WTOE = 1), but a new message should be

available on the next read.

One important use of the WTOE bit is to allow the microcontroller to program multiple message centers with the same ID when oper-

ating in the receive mode, with WTOE = 0. This allows the CAN module to store multiple incoming messages in a series of message

centers, creating a large storage area for high-speed recovery of large amounts of data. The CPU is required to manage the use of

these message centers to keep track of the incoming data, but the use of multiple message centers and disabling of their overwrite

(WTOE = 0) function prevents the module from potentially losing data during a high-speed data transfer.

The following examples demonstrate the use of the WTOE and other bits when using multiple message centers with the same arbitra-

tion value. Case 2 illustrates the approach described above for configuring multiple message centers to capture a large amount of

data at a relatively high rate.

Maxim Integrated

Advertising