Nevermind - it was my timer that was off....
I have a 16MHz crystal attached to XTAL2 pin. I want a bus speed of 8MHz.
I set the PLL with:
// Initialize the clock
// Configure the XOSC1 clock
CCSCTRL = 0x08; // XOSC1 at low frequency, low power, inactive, use oscillator, select XOCS2 as input
MCGC2 = 0x36 // Divide by 1, high frequency, high gain, FLL not disable in bypass,
// use oscillator, clock active, clock disabled in stop.
// Wait until external reference is stable
while (MCGSC_OSCINIT == 0) ;
// Set the PEE
MCGC3 |= 0x10; // set DIV32 (bit 4) in MCGC3
MCGC1 = 0x98; // external clock, divide by 256
// Wait until the external reference is selected
while (MCGSC_IREFST != 0) ;
// Wait until external clock is selected as a bus clock reference
while ((MCGSC_CLKST) != 2) ;
MCGC3 = 0x52; // Set PLL (PLL ref divider of 16), leave DIB32 (not used in PLL), VDIV = 2, (multiply by 8)
while (MCGSC_PLLST == 0);
while (MCGSC_LOCK == 0);
MCGC1 = 0x18;
while (MCGSC_CLKST != 3);
I have a timer and toggle an output in that timer. Using the oscilloscope, I see the timer values are all off. Am I setting up the PLL wrong?
Hi,
From the sample code you provide, it seems no error. Did you have any progress on this issue?