When I initialize flexcan, the set of maximum number of mailboxes invaild sometimes.Before set the maximum number of mailboxes, I did soft reset can and then,wait for reset cycle to complete.After this configuration, I find that the value of MAXMB in resgister MCR will goes back to the default value:0x0f sometimes.
But,if I delay 1ms after soft reset ,the invaild of MAXMB never happens.Did I missing some steps?
Here is my code:
/* Reset the FLEXCAN */
base->MCR = (base->MCR & ~CAN_MCR_SOFTRST_MASK) | CAN_MCR_SOFTRST(1U);
/* Wait for reset cycle to complete */
while (((base->MCR & CAN_MCR_SOFTRST_MASK) >> CAN_MCR_SOFTRST_SHIFT) != 0U){}
// hwDelay(1000);
base->MCR = (base->MCR & ~CAN_MCR_MAXMB_MASK) | CAN_MCR_MAXMB(31);