AnsweredAssumed Answered

Mode and Clock Init Problem MPC56xx

Question asked by Borja Gomez on Nov 3, 2015
Latest reply on Nov 3, 2015 by Martin Kovar

Hi,

 

I have a problem during Modes and clocks initialization process in MCP5602C microcontroller.

 

The transition to Mode 0 is not performed and the micros cannot complete tje mode transition.

 

I have tried with examples from CodeWarrior and code generated with Rappid tool, but the problem appears in both cases.

The execution gets blocked in while (ME.GS.B.S_MTRANS) {}     /* Wait for mode transition to complete */  

 

Is there any wrong with this init code? May be it could be something related with HW (1.2 regulator?)? 3.3V power supply is OK.

 

Thank you in advance

 

Borja

 

 

int main(void) {

  volatile int i = 0;

 

 

 

 

 

  initModesAndClock();  /* MPC56xxP/B/S: Initialize mode entries, set sysclk = 64 MHz*/

  disableWatchdog();    /* Disable watchdog */

  initPeriClkGen();       /* Initialize peripheral clock generation for DSPIs */

 

 

 

 

  /* Loop forever */

  for (;;)

  {

    i++;

  }

}

 

void initModesAndClock(void)

{

   ME.MER.R = 0x0000001D;           /* Enable DRUN, RUN0, SAFE, RESET modes */

                                    /* Initialize PLL before turning it on: */

   CGM.FMPLL_CR.R = 0x02400100;     /* 8 MHz xtal: Set PLL0 to 64 MHz */ 

   ME.RUN[0].R = 0x001F0074;       /* RUN0 cfg: 16MHzIRCON,OSC0ON,PLL0ON,syclk=PLL0 */

   ME.RUNPC[1].R = 0x00000010;   /* Peri. Cfg. 1 settings: only run in RUN0 mode */

   ME.PCTL[32].R = 0x01;       /* MPC56xxB/P/S ADC 0: select ME.RUNPC[1] */

   ME.PCTL[68].R = 0x01;       /* MPC56xxB/S SIU: select ME.RUNPC[1] */

                                    /* Mode Transition to enter RUN0 mode: */

   ME.MCTL.R = 0x40005AF0;         /* Enter RUN0 Mode & Key */

   ME.MCTL.R = 0x4000A50F;         /* Enter RUN0 Mode & Inverted Key */

   while (ME.GS.B.S_MTRANS) {}     /* Wait for mode transition to complete */  

                                    /* Note: could wait here using timer and/or I_TC IRQ */

   while(ME.GS.B.S_CURRENTMODE != 4) {} /* Verify RUN0 is the current mode */

}

 

void initPeriClkGen(void)

{

/* Use the following code as required for MPC56xxB or MPC56xxS:*/

  CGM.SC_DC[2].R = 0x80;   /* MPC56xxB/S: Enable peri set 3 sysclk divided by 1 */

}

 

 

void disableWatchdog(void)

{

  SWT.SR.R = 0x0000c520;     /* Write keys to clear soft lock bit */

  SWT.SR.R = 0x0000d928;

  SWT.CR.R = 0x8000010A;     /* Clear watchdog enable (WEN) */

}  

Outcomes