16.7.2.1 Configuring a Mailbox for Transmit
To transmit a message, the following steps need to be performed (in this example, for mailbox 1):
1. Clear the appropriate bit in the CANTRS register to 0:
Clear CANTRS.1 = 0 (Writing a 0 to TRS has no effect; instead, set TRR.1 and wait until TRS.1 clears.) If
the RTR bit is set, the TRS bit can send a remote frame. Once the remote frame is sent, the TRS bit of the
mailbox is cleared by the CAN module. The same node can be used to request a data frame from another
node.
2. Disable the mailbox by clearing the corresponding bit in the mailbox enable (CANME) register.
Clear CANME.1 = 0
3. Load the message identifier (MSGID) register of the mailbox. Clear the AME (MSGID.30) and AAM
(MSGID.29) bits for a normal send mailbox (MSGID.30 = 0 and MSGID.29 = 0). This register is usually
not modified during operation. It can only be modified when the mailbox is disabled. For example:
a. Write MSGID(1) = 0x15AC0000
b. Write the data length into the DLC field of the message control field register (MSGCTRL.3:0). The RTR
flag is usually cleared (MSGCTRL.4 = 0).
c. Set the mailbox direction by clearing the corresponding bit in the CANMD register.
d. Clear CANMD.1 = 0
4. Set the mailbox enable by setting the corresponding bit in the CANME register
Set CANME.1 = 1
This configures mailbox 1 for transmit mode.
16.7.2.2 Transmitting a Message
To start a transmission (in this example, for mailbox1):
1. Write the message data into the mailbox data field.
2. Set the corresponding flag in the transmit request register (CANTRS.1 = 1) to start the transmission of the
message. The CAN module now handles the complete transmission of the CAN message.
3. Wait until the transmit-acknowledge flag of the corresponding mailbox is set (TA.1 = 1). After a successful
transmission, this flag is set by the CAN module.
4. The TRS flag is reset to 0 by the module after a successful or aborted transmission (TRS.1 = 0).
5. The transmit acknowledge must be cleared for the next transmission (from the same mailbox).
a. Set TA.1 = 1
b. Wait until read TA.1 is 0
6. To transmit another message in the same mailbox, the mailbox RAM data must be updated. Setting the
TRS.1 flag starts the next transmission. Writing to the mailbox RAM can be half-word (16 bits) or full word
(32 bits) but the module always returns 32-bit from even boundary. The CPU must accept all the 32 bits or
part of it.
16.7.2.3 Configuring Mailboxes for Receive
To configure a mailbox to receive messages, the following steps must be performed (in this example, mailbox 3):
1. Disable the mailbox by clearing the corresponding bit in the mailbox enable (CANME) register.
Clear CANME.3 = 0
2. Write the selected identifier into the corresponding MSGID register. The identifier extension bit must be
configured to fit the expected identifier. If the acceptance mask is used, the acceptance mask enable (AME)
bit must be set (MSGID.30 = 1). For example:
Write MSGID(3) = 0x4F780000
3. If the AME bit is set to 1, the corresponding acceptance mask must be programmed.
Write LAM(3) = 0x03C0000.
4. Configure the mailbox as a receive mailbox by setting the corresponding flag in the mailbox direction register
(CANMD.3 = 1). Make sure no other bits in this register are affected by this operation.
Controller Area Network (CAN)
SPRUH18I – JANUARY 2011 – REVISED JUNE 2022
TMS320x2806x Microcontrollers
1015
Copyright © 2022 Texas Instruments Incorporated
Summary of Contents for TMS320 2806 Series
Page 2: ......