Hi,
I am using an S32K311 MCU on a custom hardware board. I have configured the CAN hardware filter to accept standard CAN message IDs in the range 0x7E8 to 0x7EF. However, I am still able to receive CAN messages with other IDs.
Observation:
I initialize the CAN controller while it is in Freeze mode.
After initialization, I configure the CAN hardware filter.
The RXIMR[0] register is successfully updated with the expected mask value (0x000007F8).
However, immediately after exiting Freeze mode, the RXIMR[0] register is cleared (reset to 0).
Expected Behavior:
The RXIMR[0] register should retain the configured mask value after exiting Freeze mode so that the CAN controller accepts only message IDs in the range 0x7E8 to 0x7EF.
Actual Behavior:
After executing FlexCAN_Ip_SetStartMode(instance), the RXIMR[0] register is cleared, and the CAN controller starts receiving messages with all IDs.
CAN Configuration:
Standard ID mailbox configuration:
static Flexcan_Ip_DataInfoSetType FlexcanDataInfoArray[] =
{
{
.mbIdx = RX_STD_MB_IDX,
.msgId = 0x000007E8U,
.mask = 0x000007F8U,
.dataInfo = {
.msg_id_type = FLEXCAN_MSG_ID_STD,
.data_length = 8U,
.is_polling = FALSE,
.is_remote = FALSE
},
.rxBuffer = &RxBuffer[0]
}
};CAN Initialization Sequence:
void CAN_HAL_Init(uint8 instance, MCS_CanBaudType selectedBaudrate,
uint8 stack, CAN_CommType commMode)
{
FlexCAN_Ip_DisableInterrupts(instance);
for (uint8 idx = 0U; idx < FlexcanDataInfo.numInfo; idx++)
{
FlexCAN_Ip_AbortTransfer(instance,
FlexcanDataInfo.canInfo[idx].mbIdx);
}
FlexCAN_Ip_EnterFreezeMode(instance);
while (!CAN_IsControllerInFreezeMode(instance))
{
/* Wait for Freeze mode */
}
Flexcan_Ip_ConfigType localConfig = FlexCAN_Config0;
Can_Stack_Status = stack;
CAN_CommSts.CommSt = CAN_COMM_RUN;
switch (selectedBaudrate)
{
case CAN_BAUDRATE_500K:
localConfig.bitrate.preDivider = 1U;
break;
case CAN_BAUDRATE_250K:
localConfig.bitrate.preDivider = 3U;
break;
default:
return;
}
switch (commMode)
{
case NORMAL_MODE:
localConfig.flexcanMode = FLEXCAN_NORMAL_MODE;
break;
case LISTEN_MODE:
localConfig.flexcanMode = FLEXCAN_LISTEN_ONLY_MODE;
break;
case FREEZE_MODE:
localConfig.flexcanMode = FLEXCAN_FREEZE_MODE;
break;
default:
localConfig.flexcanMode = FLEXCAN_LISTEN_ONLY_MODE;
break;
}
#if ((VDR == TGT_311) || (VDR == TGT_322))
CAN_Transceiver_SetNormalMode();
#elif (VDR == EVK_344)
TJA1443_SetMode(TJA1443_MODE_NORMAL);
#endif
FlexCAN_Ip_Init(instance, &FlexCAN_State0, &localConfig);
CAN_HAL_EnableErrorInterrupts(instance);
FlexCAN_Ip_SetRxMaskType(instance, FLEXCAN_RX_MASK_INDIVIDUAL);
for (uint8 idx = 0U; idx < FlexcanDataInfo.numInfo; idx++)
{
Flexcan_Ip_DataInfoSetType *mbInfo =
&FlexcanDataInfo.canInfo[idx];
FlexCAN_Ip_SetRxIndividualMask(instance,
mbInfo->mbIdx,
mbInfo->mask);
FlexCAN_Ip_ConfigRxMb(instance,
mbInfo->mbIdx,
&mbInfo->dataInfo,
mbInfo->msgId);
FlexCAN_Ip_Receive(instance,
mbInfo->mbIdx,
mbInfo->rxBuffer,
FALSE);
}
FlexCAN_Ip_SetStartMode(instance);
while (CAN_IsControllerInFreezeMode(instance))
{
/* Wait until the controller exits Freeze mode */
}
IntCtrl_Ip_EnableIrq(FlexCAN0_1_IRQn);
IntCtrl_Ip_EnableIrq(FlexCAN0_0_IRQn);
FlexCAN_Ip_EnableInterrupts(instance);
}Support Required:
Why is the RXIMR[0] register cleared after executing FlexCAN_Ip_SetStartMode(instance)?
Is there anything incorrect in my CAN initialization sequence?
Is there any additional configuration required to retain the individual RX mailbox mask values after exiting Freeze mode?
Could this behavior be related to the FlexCAN driver implementation or the S32K311 hardware configuration?
Could you please review the initialization sequence and provide guidance on how to resolve this issue?
Thanks.