Mode and Clock Init Problem MPC56xx

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Mode and Clock Init Problem MPC56xx

1,266件の閲覧回数
borjagomez
Contributor I

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) */

}  

ラベル(1)
0 件の賞賛
返信
1 返信

987件の閲覧回数
martin_kovar
NXP Employee
NXP Employee

Hi Borja,

I have just tested your init code and it seems to be correct. Just to make sure try this init code:

void InitModesAndClks(void) {

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

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

      ME.RUNPC[0].R = 0x000000FE; /* enable peripherals run in all modes */

      ME.RUN[0].R = 0x001F0074;       /* RUN0 cfg: IRCON,OSC0ON,PLL0ON,syclk=PLL */

      /* 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 */

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

}

But it seems there will be another problem (crystal for example). Look at the Mode Entry Global Status register and eventually post here the register dump.

Regards,

Martin

0 件の賞賛
返信