AnsweredAssumed Answered

MPC5746C CAN Frozen. Stuck in Frz Mode. DRUN mode fails

Question asked by Holland on Mar 19, 2018
Latest reply on Mar 22, 2018 by Holland

Hi,

 

I am not sure what the problem is, but for some reason, I am stuck in FRZ mode.

It might be stuck in 'Stop Mode', since the NOTRDY = 1 and LMPACK = 1. 

 

I'm not sure if this is related or not, but I can't seem to enter DRUN mode, only RUN0 mode.

We are running on new hardware, So I am led to believe this might be some sort of hardware issue.

Is there any reason, other than hardware, that it would not transition into DRUN mode?

 

I used the clock initialization example in "MPC574xC_Clock_Calculator_Rev6.xlsm"

The code gets stuck in the while(MC_ME.GS.B.S_MTRANS) loop.

I can transition to mode 4 (RUN0), but it will not transition to mode 3 (DRUN).

I'm not sure if this is directly related to the CAN issue or not?

 

MC_ME.PCTL[70].R = 1;  /* Might not even need this. All peripherals might be set */
//CAN_0_config_pins(); /* pins aren't needed at this point */
//CAN_FlexCAN_0_config_rx_msg_buffers(); /* Don't need these either */

int i = 0;

/* Module disable */
CAN_0.MCR.B.MDIS = 1;


/* Select Clock */
CAN_0.CTRL1.B.CLKSRC = 0;

/* Module enable */
CAN_0.MCR.B.MDIS = 0;

CAN_0.MCR.B.HALT = 1;
CAN_0.MCR.B.FRZ = 1;

while(0 == CAN_0.MCR.B.FRZACK ){}   /* <----- Stuck */
while(0 == CAN_0.MCR.B.NOTRDY ){}

CAN_0.MCR.B.SOFTRST = 1;
while(1 == CAN_0.MCR.B.SOFTRST == 1){};

 

 

This is the SysClk_Init() function. It will successfully transition to mode RUN0, but will not transition to Default DRUN mode.

 

void SysClk_Init(void)
{

MC_CGM.AC5_SC.R = 0x01000000; //Connect FXOSC to the FMPLL input.

//Set FMPLL to MHz with 16 MHz FXOSC reference.
PLLDIG.PLLDV.R = 0x04010028; //PREDIV = 0, MFD = 40, RFDPHI = 1, RFDPHI1 = 2
PLLDIG.PLLFD.R = 0x00000000; //PLL fractional numerators
PLLDIG.PLLCAL3.R = 0x00004000; //PLL fractional denominator

//Turn on clock sources and select system clock source
MC_ME.DRUN_MC.R = 0x00130172; //Configure DRUN mode settings with sysclk FMPLL_PHI0 (160 MHz).

MC_ME.ME.R = 0;
MC_ME.ME.R = 0x0000A4FD; /* Enable RUN1-3, STOP0, STANDBY0 */
MC_ME.RUN_PC[0].R = 0x000000FE; //Enable peripherals to run in all modes

//Configure the oscillator divided clocks
SIRC.CTL.R = 0x00000011; //SIRC_DIV_CLK is SIRC divided by 1 (0.128 MHz).
FIRC.CTL.R = 0x00000011; //FIRC_DIV_CLK is FIRC divided by 1 (16 MHz).
SXOSC.CTL.B.OSCDIV = 0x00; //SXOSC_DIV_CLK is SXOSC divided by 1 (0.032 MHz).
//FXOSC.CTL.B.OSCDIV = 0x00; //FXOSC_DIV_CLK is FXOSC divided by 1 (16 MHz).

/* Change to RUN0 */
/* write new mode and key */
MC_ME.MCTL.R = 0x40005AF0ul;
/* write new mode and inverted key */
MC_ME.MCTL.R = 0x4000A50Ful;
while(MC_ME.GS.B.S_MTRANS); //Wait for mode transition to complete
while(MC_ME.GS.B.S_CURRENT_MODE != 0x4); //Verify DRUN is the current mode


//Mode transition to DRUN mode:
MC_ME.MCTL.R = 0x30005AF0; //Enter DRUN mode & Key
MC_ME.MCTL.R = 0x3000A50F; //Enter DRUN mode & Inverted Key
while(MC_ME.GS.B.S_MTRANS); //Wait for mode transition to complete
while(MC_ME.GS.B.S_CURRENT_MODE != 0x3); //Verify DRUN is the current mode
}

 

 

P.S. I wonder if I need to transition to DRUN mode if the mode is already mode 3?

       Something else seems to not work if I skip the mode switch and just assume its in mode DRUN already.

 

Thank you,

Outcomes