11.3.10 Configuring a Receive Message Object
The following steps show how to configure a receive message object.
- Program the CAN IFn Command Mask (CANIFnCMSK) register as described in the Section 11.3.4 section, except that the WRNRD bit is set to specify a write to the message RAM.
- Program the CANIFnMSK1 and CANIFnMSK2 registers as described in the Section 11.3.4 section to configure which bits are used for acceptance filtering. Note that 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. For these bits to be used for acceptance filtering, they must be enabled by setting the UMASK bit in the CANIFnMCTL register.
- Program the CANIFnARB1 and CANIFnARB2 registers as described in Section 11.3.4 to program XTD and ID bits for the message identifier to be received; set the MSGVAL bit to indicate a valid message; and clear the DIR bit to specify receive.
- 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 RXIE bit to enable the INTPND bit to be set after a successful reception.
- Clear the RMTEN bit to leave the TXRQST bit unchanged.
- 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.
- Program the number of the message object to be received in the MNUM field in the CAN IFn Command Request (CANIFnCRQ) register. Reception of the message object begins as soon as a matching frame is available on the CAN bus.
When the message handler stores a data frame in the message object, it stores the received data length code and eight data bytes in the CANIFnDA1, CANIFnDA2, CANIFnDB1, and CANIFnDB2 registers. Byte 0 of the CAN data frame is stored in DATA[7:0] in the CANIFnDA1 register. If the data length code is less than 8, the remaining bytes of the message object are overwritten by unspecified values.
The CAN mask registers can be used to allow groups of data frames to be received by a message object. The CAN mask registers, CANIFnMSKn, configure which groups of frames are received by a message object. The UMASK bit in the CANIFnMCTL register enables the MSK bits in the CANIFnMSKn register to filter which frames are received. The MXTD bit in the CANIFnMSK2 register should be set if only 29-bit extended identifiers are expected by this message object.