11.3.4 Configuring a Transmit Message Object
The following steps explain how to configure a transmit message object.
- In the CAN IFn Command Mask (CANIFnCMSK) register:
- Set the WRNRD bit to specify a write to the CANIFnCMSK register; specify whether to transfer the IDMASK, DIR, and MXTD of the message object into the CAN IFn registers using the MASK bit.
- Specify whether to transfer the ID, DIR, XTD, and MSGVAL of the message object into the interface registers using the ARB bit.
- Specify whether to transfer the control bits from the CANIFnMCTL (CAN message control) register into the interface registers using the CONTROL bit.
- Specify whether to clear the INTPND bit (which indicates if the given message is the source of an interrupt) in the CANIFnMCTL register using the CLRINTPND bit.
- Specify whether to clear the NEWDAT bit in the CANNWDAn register (which indicates if new data is available for each of 32 message objects) using the NEWDAT bit.
- Specify which bytes to transfer using the DATAA and DATAB bits. The DATAA bit in CANIFnCMSK enables transfer of data bytes 0 to 3 to or from the message object. Similarly, the DATAB bit controls data bytes 4 to 7.
- In the CANIFnMSK1 register, use the MSK[15:0] bits to specify which of the bits in the 29-bit or 11-bit message identifier are used for acceptance filtering. The bits MSK[15:0] in this register are used for bits [15:0] of the 29-bit message identifier and are not used for an 11-bit identifier. A value of 0x00 enables all messages to pass through the acceptance filtering. For these bits to be used for acceptance filtering, they must be enabled by setting the UMASK bit in the CANIFnMCTL register.
- In the CANIFnMSK2 register, use the MSK[12:0] bits to specify which of the bits in the 29-bit or 11-bit message identifier are used for acceptance filtering. Note that MSK[12:0] are used for bits [28:16] of the 29-bit message identifier; whereas MSK[12:2] are used for bits [10:0] of the 11-bit message identifier. Use the MXTD and MDIR bits to specify whether to use XTD and DIR for acceptance filtering. A value of 0x00 enables all messages to pass through the acceptance filtering. Also note that for these bits to be used for acceptance filtering, they must be enabled by setting the UMASK bit in the CANIFnMCTL register.
- For a 29-bit identifier:
- Configure ID[15:0] in the CANIFnARB1 register for bits [15:0] of the message identifier.
- Configure ID[12:0] in the CANIFnARB2 register for bits [28:16] of the message identifier.
- Set the XTD bit to indicate an extended identifier.
- Set the DIR bit to indicate transmit.
- Set the MSGVAL bit to indicate that the message object is valid.
- For an 11-bit identifier:
- Disregard the CANIFnARB1 register.
- Configure ID[12:2] in the CANIFnARB2 register for bits [10:0] of the message identifier.
- Clear the XTD bit to indicate a standard identifier.
- Set the DIR bit to indicate transmit.
- Set the MSGVAL bit to indicate that the message object is valid.
- In the CANIFnMCTL register:
- Optionally set the UMASK bit to enable the mask (MSK, MXTD, and MDIR specified in the CANIFnMSK1 and CANIFnMSK2 registers) for acceptance filtering.
- Optionally set the TXIE bit to enable the INTPND bit to be set after a successful transmission.
- Optionally set the RMTEN bit to enable the TXRQST bit to be set on the reception of a matching remote frame allowing automatic transmission.
- Set the EOB bit for a single message object.
- Configure the DLC[3:0] field to specify the size of the data frame. Take care during this configuration not to set the NEWDAT, MSGLST, INTPND, or TXRQST bits.
- Load the data to be transmitted into the CAN IFn Data (CANIFnDA1, CANIFnDA2, CANIFnDB1, CANIFnDB2) registers. Byte 0 of the CAN data frame is stored in DATA[7:0] in the CANIFnDA1 register.
- Program the number of the message object to be transmitted in the MNUM field in the CAN IFn Command Request (CANIFnCRQ) register.
- When everything is properly configured, set the TXRQST bit in the CANIFnMCTL register. When this bit is set, the message object is available to be transmitted, depending on priority and bus availability. Setting the RMTEN bit in the CANIFnMCTL register can also start message transmission if a matching remote frame has been received.