Hi,
the link you mentioned does not work for me.
Anyway, RXIMR and RXMGMASK setting you have should be OK. If MCR[IRMQ] is cleared then individual masking registers are not used and masking is based on RXMGMASK, RX14MASK, RX15MASK registers (RX14MASK, RX15MASK is for MB14 and MB15).
So if you have RXMGMASK = 0x1FFFFFFF then there must be exact match between incoming ID and the one programmed in MB ID.
You can rewrite FLEXCAN0_receive_msg to have input parameter saying which MB to read, eg.
void FLEXCAN0_receive_msg(uint8_t mbnum)
{
/*! Receive msg using msg buffer "mbnum"
* =============================================
*/
uint8_t j;
uint32_t dummy;
RxCODE = (CAN0->RAMn[ mbnum*MSG_BUF_SIZE + 0] & 0x07000000) >> 24; /* Read CODE field */
RxID = (CAN0->RAMn[ mbnum*MSG_BUF_SIZE + 1] & CAN_WMBn_ID_ID_MASK) >> CAN_WMBn_ID_ID_SHIFT; /* Read ID */
RxLENGTH = (CAN0->RAMn[ mbnum*MSG_BUF_SIZE + 0] & CAN_WMBn_CS_DLC_MASK) >> CAN_WMBn_CS_DLC_SHIFT; /* Read Message Length */
for (j=0; j<2; j++)
{ /* Read two words of data (8 bytes) */
RxDATA[j] = CAN0->RAMn[ mbnum*MSG_BUF_SIZE + 2 + j];
}
RxTIMESTAMP = (CAN0->RAMn[ mbnum*MSG_BUF_SIZE + 0] & 0x000FFFF);
dummy = CAN0->TIMER; /* Read TIMER to unlock message buffers */
CAN0->IFLAG1 = 1 << mbnum; /* Clear CAN 0 MB "mbnum" flag without clearing others*/
}
BR, Petr