How to initialize the clock about the SPC560P50L5/MPC5604P?

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

How to initialize the clock about the SPC560P50L5/MPC5604P?

788 Views
ananan
Contributor III

The microcontroller what I used is the SPC560P50L5,but the referance datasheet is base on the MPC5604P.微信截图_20180517112437.png

this is how I initialize it .when I use these codes  in MPC5604P which the  external oscillator is 40MHZ,It operation well .but when I use these codes  in SPC560P50L5which the  external oscillator is 12MHZ,it does not work ,the program is stoped at the code "while (ME.GS.B.S_MTRANS){};"when I debug it.  

1.png

2.png

Please help me , thank you very much!

3 Replies

638 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

This can be due to CMU unit which checks the crystal frequency as soon as the crystal is enabled in the Mode Entry.

The CMU_0 must be initialized differently from the default value in case of 12 MHz crystal. By defaut it is checked against IRC/1. Try to set CMU_0.CSR[RCDIV] = 3 before you enable XOSC in Mode Entry.

BR, Petr

638 Views
ananan
Contributor III

1.png

2.png

I try these codes,but the result is also does not work!The program stop at the while (CGM.FMLL[0].CR.B.LOCK==0){};3.png  I have set the  CMU_0.CSR[RCDIV] = 3

0 Kudos
Reply

638 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

try to use below code

/* Enter RUN0 with PLL as sys clk (64 MHz) with 12 MHz crystal reference. */
void InitModesAndClks(void) {
    ME.MER.R = 0x0000001D;        /* Enable DRUN, RUN0, SAFE, RESET modes */

    CGM.CMU_0_CSR.R = 0x000000004;  /* Monitor FXOSC > FIRC/4 (4MHz); no PLL monitor */
    CGM.FMPLL_CR.R = 0x09400100;    /* 12MHz 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 */
}

BR, Petr