50.8.3.1.2 Receive with Overwrite Mailbox

A mailbox is in Receive with Overwrite mode once the CAN_MMRx.MOT field has been configured. Message ID and Message Acceptance masks must be set before Receive mode is enabled.

After Receive mode is enabled, the MRDY flag in CAN_MSR is automatically cleared until the first message is received. When the first message has been accepted by the mailbox, the MRDY flag is set. An interrupt is pending for the mailbox while the MRDY flag is set. This interrupt is masked depending on the mailbox flag in the CAN_IMR global register.

If a new message is received while the MRDY flag is set, this new message is stored in the mailbox data register, overwriting the previous message. The MMI flag in CAN_MSRx notifies the software that a message has been dropped by the mailbox. This flag is cleared when reading CAN_MSRx.

The CAN controller may store a new message in the CAN data registers while the application reads them. To check that CAN_MDHx and CAN_MDLx do not belong to different messages, the application must check the CAN_MSRx.MMI bit before and after reading CAN_MDHx and CAN_MDLx. If the MMI flag is set again after the data registers have been read, the software application has to re-read CAN_MDHx and CAN_MDLx (see the figure below).
Figure 50-12. Receive with Overwrite Mailbox