AnsweredAssumed Answered

the problem  about initializing the clock about the SPC560P50L5/MPC5604P?

Question asked by an an on May 17, 2018
Latest reply on May 28, 2018 by Martin Kovar

the is my initialize the clock in the SPC560P50L5.

 

void MS_Initial_CGM(void)
{
//Set PLL0
CGM.FMPLL[0].CR.B.IDF = 0x02; //PLL0 输入分频因子 40MHz/10//0x09
CGM.FMPLL[0].CR.B.ODF = 0x01; //PLL0 输出分频因子 4Mhz/4
CGM.FMPLL[0].CR.B.NDIV= 0x40; //1MHzX64=64Mhz
//Set PLL1
CGM.FMPLL[1].CR.B.IDF = 0X02; //PLL1 输入分频因子 40MHz/10//0x09
CGM.FMPLL[1].CR.B.ODF = 0x01; //PLL1 输出分频因子 4Mhz/4
CGM.FMPLL[1].CR.B.NDIV= 0x40; //1MHzX80=80Mhz

ME.MER.R = 0x000005FF; //使能所有工作模式
ME.DRUN.B.DFLAON = 0x3; //数据flash工作在Normal模式
ME.DRUN.B.CFLAON = 0x3; //程序flash工作在Normal模式
ME.DRUN.B.PLL1ON = 0x1; //开PLL1
ME.DRUN.B.PLL2ON = 0x1; //开PLL2
ME.DRUN.B.XOSC0ON= 0x1; //开OSC
ME.DRUN.B.IRCON = 0x1; //开RC
ME.DRUN.B.SYSCLK= 0x4; //系统时钟选择PLL

ME.RUNPC[0].R = 0x001F00FE; //使能所有外设的工作模式
ME.LPPC[0].R = 0x00000500; //低电压下stop和Half模式有效

CGM.AC0SC.B.SELCTL = 0x2; //辅助时钟0选择晶振
CGM.AC1SC.B.SELCTL = 0x0; //辅助时钟1选择PLL1
CGM.AC3SC.B.SELCTL = 0x5; //辅助时钟2选择PLL1

CGM.OCEN.R = 0x1; //使能时钟输出
CGM.OCDSSC.B.SELCTL = 0x3; //时钟输出选择PLL1
CGM.OCDSSC.B.SELDIV = 0x3; //分频因子8
CGM.AC0DC.B.DE0 = 0x1; //使能辅助时钟0
CGM.AC0DC.B.DIV0 = 0x0; //分频因子0
CGM.AC1DC.B.DE0 = 0x1; //使能辅助时钟1
CGM.AC2DC.B.DE0 = 0x1; //使能辅助时钟2
CGM.AC3DC.B.DE0 = 0x1; //使能辅助时钟3

CGM.CMU_0_CSR.B.RCDIV = 3; //RC振荡器分频因子8
CGM.CMU_0_LFREFR_A.B.LFREF_A = 0x1; //低频
CGM.CMU_0_HFREFR_A.B.HFREF_A = 0xFFE; //高频

//disable watchdog

SWT.SR.R = 0x0000C520;
SWT.SR.R = 0x0000D928;
SWT.CR.R = 0x8000010A;

ME.MCTL.R = (0x3 << 28 | 0x00005AF0); //DRUN & KEY
ME.MCTL.R = (0x3 << 28 | 0x0000A50F); //DRUN & KEY

while(CGM.FMPLL[0].CR.B.S_LOCK==0){}; //等待PLL0稳定
while(CGM.FMPLL[1].CR.B.S_LOCK==0){}; //等待PLL1稳定

while(ME.GS.B.S_MTRANS == 1){}; //等待模式运行
while(ME.GS.B.S_CURRENTMODE != 0x3){}; //判断DRUN模式是否运行
}

 

 

 

but when I debug the program,the program is stoped at the next station.

when I used these code in the MPC5604P,it operation well.I do not how to solve the problem ,Please help me thank you very much!

Outcomes