Hi Senlent
Thank you for your answer, which has been of great help to me.
I want to set the global mask RTR bit and IDE to receive remote frames. However, I found that using your configuration is not able to receive them.
Then, after I configured RTR=1 in the MB, I was able to only receive remote frames.
Due to the incomplete configuration of the library functions in the SDK for MB and global mask, in reality your example only performs the corresponding logical judgment based on the ID.
As shown in the figure, I used your DEMO. In fact, for both data frames and remote frames, as long as the ID is 0x105, they will be received. I think this is not very rigorous.
My suggestions are as follows:
If you want to accurately receive remote frames, the following configuration is required
/*RRS = 1*/
FLEXCAN_EnterFreezeMode(CAN0);
/*Set global mask (IDE and RTR)*/
CAN0->RXMGMASK = 0xC0000000;
CAN0->RX14MASK = 0xC0000000;
CAN0->RX15MASK = 0xC0000000;
CAN0->CTRL2 = (CAN0->CTRL2 & ~CAN_CTRL2_EACEN_MASK) | CAN_CTRL2_EACEN(1);
/* Enable Global RX masking */
CAN0->CTRL2 = (CAN0->CTRL2 & ~CAN_CTRL2_RRS_MASK) | CAN_CTRL2_RRS(1U);
FLEXCAN_ExitFreezeMode(CAN0);
And must set MB(RTR=1).Then you can only receive the remote frames and then perform logical judgment processing.
(The above examples are only applicable to the global mask. If you wish to set a specific MB, you need to configure the corresponding RXIMR.)