S32K148 is stalled in the MCR_FRZACK checked while loop in flexcan_hw_access.c

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K148 is stalled in the MCR_FRZACK checked while loop in flexcan_hw_access.c

874 Views
Leon_Hsieh
Contributor II

Hi all, 

I have some problem about the CAN FreezeMode.

I was testing our own designed board, when I kept feeding the CAN message from CANoe to S32K148, and trying to re-start the mcu(using power on-off). in some case, the code might be stalled. And then I used S32DS to attach the MCU, I found that the program was stalled in the while loop

/* Wait for entering the freeze mode */
while (((base->MCR & CAN_MCR_FRZACK_MASK) >> CAN_MCR_FRZACK_SHIFT) == 0U) {}

in the FLEXCAN_EnterFreezeMode in the SDK file flexcan_hw_access.c.

Once the program was stalled in the while loop,  the CANoe keeping feeding the CAN message, then power-off then power-on again. After that, the program is still kept in the same while loop.

When the program stalled, how to make S32K148 going to Freeze mode and also MCR_FRZACK  1?

Is anyone ever having this problem before?

 

Spoiler

void FLEXCAN_EnterFreezeMode(CAN_Type * base)
{
bool enabled = false;

base->MCR = (base->MCR & ~CAN_MCR_FRZ_MASK) | CAN_MCR_FRZ(1U);
base->MCR = (base->MCR & ~CAN_MCR_HALT_MASK) | CAN_MCR_HALT(1U);
if (((base->MCR & CAN_MCR_MDIS_MASK) >> CAN_MCR_MDIS_SHIFT) == 0U)
{
enabled = true;
}
else
{
base->MCR &= ~CAN_MCR_MDIS_MASK;
}
#ifdef ERRATA_E9595
/* Check Low-Power Mode Acknowledge Cleared */
while (((base->MCR & CAN_MCR_LPMACK_MASK) >> CAN_MCR_LPMACK_SHIFT) == 1U) {}
/* Check if is a Bus-Off Error corresponding to 1x */
if ((((base->ESR1 & CAN_ESR1_FLTCONF_MASK) >> CAN_ESR1_FLTCONF_SHIFT) & 2U) != 0U)
{
/* Save registers before Soft Reset */
uint32_t tempIMSK[2],tempMCR;
tempIMSK[0] = base->IMASK1;
tempIMSK[1] = base->IMASK2;
tempMCR = base->MCR;
/* Soft Reset FlexCan */
base->MCR |= CAN_MCR_SOFTRST(1U);
while (((base->MCR & CAN_MCR_SOFTRST_MASK) >> CAN_MCR_SOFTRST_SHIFT) == 0U) {}
/* Restore registers after Soft Reset */
base->IMASK1 = tempIMSK[0];
base->IMASK2 = tempIMSK[1];
base->MCR = tempMCR;
}
else
{
base->MCR = (base->MCR & ~CAN_MCR_HALT_MASK) | CAN_MCR_HALT(1U);
}
#endif
/* Wait for entering the freeze mode */
while (((base->MCR & CAN_MCR_FRZACK_MASK) >> CAN_MCR_FRZACK_SHIFT) == 0U) {}
if (false == enabled)
{
base->MCR |= CAN_MCR_MDIS_MASK;
/* Wait until disable mode acknowledged */
while (((base->MCR & CAN_MCR_LPMACK_MASK) >> CAN_MCR_LPMACK_SHIFT) == 0U) {}
}
}

#S32K148

 

0 Kudos
4 Replies

862 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Leon_Hsieh,

It looks like you are using an older version of the SDK. Have you tried the S32K1 SDK RTM 4.0.2 or 4.0.3?

Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

Tags (1)
0 Kudos

855 Views
Leon_Hsieh
Contributor II

Hi Robin_Shen,

Thanks for your reply.

I am using the SDK RTM 3.0.0 source code.

Is any problem with the different version? And how can I fix the CAN issues?

Thank you

Leon

0 Kudos

848 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Yes. As I know, SDK RTM 4.0.3 fixed this issue. You can check it.

0 Kudos

831 Views
Leon_Hsieh
Contributor II

I change the RTM from 3.0.0 to 4.0.3, and it's working. I also tried 4.0.2 but it isn't working either.


Thanks for your help.