AnsweredAssumed Answered


Question asked by Briceag Bebe-Cosmin on Nov 6, 2016
Latest reply on Nov 8, 2016 by Robin_Shen



I try to configure the PLL of the KL46Z FRDM board with an 8MHz external oscillator. I followed every step from the datasheet in order to switch the MCG from FEI to PEE mode, but nothing happens. I'm expecting to light up  two LEDs every one second.


#include "derivative.h" 

#define CLKSTS_MASK 0x08
#define CLKST_MASK  0x0C

static void BootClockRUN();

void setup(void)


         SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK; /*System Clock Gating Control Register 5 (SIM_SCGC5)*/
         SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK; /*Enable clock for PORT E setting bit field PORTE*/
                                            /*Also enable clock for PORT D setting bit field PORTE*/
         PORTE_PCR29 = PORT_PCR_MUX(1);      /*Pin Control Register n (PORTx_PCRn)*/
         PORTD_PCR5 = PORT_PCR_MUX(1);       /*Select GPIO as pin functionality on multiplexor*/
                                        /*setting field MUX=001, do this for each bit on each PORT*/
         GPIOE_PDDR |= (1 << 29);            /*Port Data Direction Register (GPIOx_PDDR)*/
         GPIOD_PDDR |= (1 << 5);          /*Set GPIO direction set bit corresponding bit on the direction*/
   unsigned long time = 48000000;
   unsigned long counter;
             GPIOE_PTOR |= (1<<29);
             for(counter = 0; counter < time; counter++){}
             GPIOD_PTOR |= (1<<5);

void BootClockRUN()
        MCG_C2 = 0x2C;
        MCG_C1 = 0x90;

        while(!(MCG_S & (1<<1)));
        while((MCG_S & (1<<4)));

        while((MCG_S & CLKSTS_MASK) != CLKSTS_MASK);

        MCG_C5 = 0x01;

        MCG_C6 = 0x40;

        while(!(MCG_S & (1<<5)));
        while(!(MCG_S & (1<<6)));

        MCG_C1 = 0x10;

       while((MCG_S & CLKST_MASK) != CLKST_MASK);



Could someone tells me what the problem is?


Thank you,

Best Regards,