Hello,
I am working on s32k144 and in particular on FlexCAN driver. I initialized the controler, everything is well working. Now, during run time, I have to update CAN ID of 2 mailboxes. For the first one, a mailbox in reception, no problem. for the second, a mailbox in transmission, impossible to change the ID ; the initial ID is still use. Can you help me ?
this is an extract of my re-init code
CAN_CHAN->MCR |= CAN_MCR_MDIS_MASK; /* MDIS=1: Disable module before selecting clock */
CAN_CHAN->MCR |= CAN_MCR_FRZ_MASK; /* MDIS=1: Disable module before selecting clock */
CAN_CHAN->MCR |= CAN_MCR_HALT_MASK; /* MDIS=1: Disable module before selecting clock */
CAN_CHAN->CTRL1 &= ~CAN_CTRL1_CLKSRC_MASK; /* CLKsrc=0: Clock Source = oscillator (8 MHz) */
CAN_CHAN->MCR &= ~CAN_MCR_MDIS_MASK; /* MDIS=0; Enable module config. (Sets FRZ, HALT)*/
while (!((CAN_CHAN->MCR & CAN_MCR_FRZACK_MASK) >> CAN_MCR_FRZACK_SHIFT)) {}
CAN_CHAN->RAMn[16] = 0x00000000;
CAN_CHAN->RAMn[17] = NewID;
CAN_CHAN->MCR &= 0x007FFFFF;
while ((CAN_CHAN->MCR && CAN_MCR_FRZACK_MASK) >> CAN_MCR_FRZACK_SHIFT) {}
/* Good practice: wait for FRZACK to clear (not in freeze mode) */
while ((CAN_CHAN->MCR && CAN_MCR_NOTRDY_MASK) >> CAN_MCR_NOTRDY_SHIFT) {}
/* Good practice: wait for NOTRDY to clear (module ready) */
Hi @Julien_GIMA,
Was the mailbox active before trying to configure a new ID? If a TX MB is activated (when CODE is set to DATA), the ID field is locked.
The cookbook assumes CODE is inactive when configuring TX MB:
You can try to ABORT transmission if active, set MB to INACTIVE, update the ID and reconfigure code for TX.
Best regards,
Julián