I have used this example from the manual but never got it to work:
Example 1: Minimal Code to Bring Up a PLL:
/* F160 - max 160 MHz (/1) */
MC_CGM.SC_DC0.B.DIV = 0;
/* S80 - max 80 MHz (/2) */
/* MC_CGM_SC_DC1[DIV] and MC_CGM_SC_DC5[DIV] must be equal at all times */
MC_CGM.SC_DC1.B.DIV = 1;
/* FS80 - max 80 MHz (/2) */
/* MC_CGM_SC_DC1[DIV] and MC_CGM_SC_DC5[DIV] must be equal at all times */
MC_CGM.SC_DC5.R = MC_CGM.SC_DC1.R; /* 80 MHz max */
/* S40 - max 40 MHz (/4) */
MC_CGM.SC_DC2.B.DIV = 3;
/* F40 - max 40 MHz (/4) */
// MC_CGM.SC_DC3.B.DIV = 3; Here I am also getting a exception so I removed this line
/* F80 - max 80 MHz */
// MC_CGM.SC_DC4.B.DIV = 1; Here I am also getting a exception so I removed this line
/* enable all modes, enable all peripherals */
MC_ME.ME.R = 0x000005FF;
MC_ME.RUN_PC[0].R = 0x000000FE;
/* Connect XOSC to PLL */
MC_CGM.AC5_SC.B.SELCTL = 1;
/* Configure PLL0 Dividers - 160MHz from 40Mhx XOSC */
PLLDIG.PLLDV.B.PREDIV = 2;
PLLDIG.PLLDV.B.MFD = 32;
PLLDIG.PLLDV.B.RFDPHI = 1;
PLLDIG.PLLCAL3.R = 0x09C3C062;
PLLDIG.PLLFD.B.SMDEN = 1; /* Sigma delta modulation enabled */
/* switch to PLL */
MC_ME.DRUN_MC.R = 0x00130172; /* FLASH in normal mode, PLLON, FXOSC ON, Use PLL_PHI_0 */
MC_ME.MCTL.R = 0x30005AF0; /* DRUN target mode + KEY */
MC_ME.MCTL.R = 0x3000A50F; /* DRUN target mode + KEY Inverted */
while(0 == MC_ME.GS.B.S_PLLON); /* ME_GS Wait for PLL stabilization */
// while(1 == MC_ME.GS.B.S_MTRANS);/* Wait for mode transition complete */ Here I never got S_MTRANS to change to 0
Now when I changed MC_ME.DRUN_MC.R from 0x00130172 to 0x00130072 it works better and I can continue with setting up the FlexCAN...
But as you can see above I still get exceptions when I try to set:
MC_CGM.SC_DC3.B.DIV = 3
MC_CGM.SC_DC4.B.DIV = 1
but it seems that this regs are setup correct anyway.
/Thanks Torbjörn