Renesas rx72m can receive mailbox Settings, called in the polling function, see details

void r_can2_receive(
const uint8_t mbox_nr,
const uint32_t id,
const uint8_t frame_type,
const uint32_t mask_value)
{

CAN2.MIER.LONG &= ((~(bit_set[mbox_nr]))); 


CAN2.MCTL[mbox_nr].BYTE = 0;
CAN2.MCTL[mbox_nr].BYTE = 0;


CAN2.MB[mbox_nr].ID.BIT.SID = (id & SID_MASK);


CAN2.MB[mbox_nr].ID.BIT.IDE = 0;
if (REMOTE_FRAME == frame_type)
{
CAN2.MB[mbox_nr].ID.BIT.RTR = 1;
}
else
{
CAN2.MB[mbox_nr].ID.BIT.RTR = 0;
}


CAN2.MCTL[mbox_nr].BYTE = 0x40;


CAN2.MKR[mbox_nr/4].BIT.SID = mask_value;


CAN2.MKIVLR.LONG &= (~(bit_set[mbox_nr]));

}

#define CANBOX_NMT_RX (0x01) //NMT

#define CANBOX_SYNC_RX (0x02) //SYNC

I've set up this receiver mailbox function in such a way that it's called when it's initialized, like in the initialization function:

//NMT Slave 0x000
r_can2_receive(CANBOX_NMT_RX, 0x000, DATA_FRAME, 0x7FF);

//SYNC consumer 0x080
r_can2_receive(CANBOX_SYNC_RX,0x080, DATA_FRAME,0x7FF);

Then determine whether the data is received in the polling function:

void R_CAN_ReceiveMessagePoll()
{

if(CAN2.MCTL[CANBOX_NMT_RX].BIT.RX.NEWDATA == 1 && CAN2.MCTL[CANBOX_NMT_RX].BIT.RX.INVALDATA == 0)
{}

if (CAN2.MCTL[CANBOX_SYNC_RX].BIT.RX.NEWDATA == 1 && CAN2.MCTL[CANBOX_SYNC_RX].BIT.RX.INVALDATA == 0)
{}

}

By this judgment statement can determine the received data and valid?

In the polling function, the NMT and SYNC, located in the first will not be used, will not receive data, located in the second will be OK, these two functions exchange order, or located in the second will be OK, what is the reason? I'd like to ask about the solution to this

}