![Texas Instruments TMS320x281 series Скачать руководство пользователя страница 73](http://html1.mh-extra.com/html/texas-instruments/tms320x281-series/tms320x281-series_reference-manual_1095203073.webp)
3.2.1 Configuring a Mailbox for Transmit
3.2.2 Transmitting a Message
3.2.3 Configuring Mailboxes for Receive
www.ti.com
Steps to Configure eCAN
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.filter1 = 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.
To start a transmission (in this example, for mailbox:
1. Write the message data into the mailbox data field.
a. Since DBO (MC.10) is set to zero in the configuration section and MSGCTRL(1) is set to 2, the
data are stored in the 2 MSBytes of CANMDL(1).
b. Write CANMDL(1) = xxxx0000h
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.
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.
SPRU074F – May 2002 – Revised January 2009
eCAN Configuration
73