AnsweredAssumed Answered

[MCF51JM128] Initial clock failed

Question asked by Pogo Lin on Dec 26, 2011
Latest reply on May 9, 2012 by mauricio fernandez montoya

Hi all,

 

I used MCF51JM128 with 8M resonator. It can download firmware with BDM. The following is my code for initial clock.

 

static void init_clock(void){    /* Assume 12MHz external clock source connected. */    /* In order to use the USB we need to enter PEE mode and MCGOUT set to 48 MHz.     Out of reset MCG is in FEI mode. */    /**** Moving from FEI (FLL engaged internal) to PEE (PLL engaged external) mode. */     /* switch from FEI to FBE (FLL bypassed external) */     /* enable external clock source *///    MCGC2 = MCGC2_HGO_MASK      /* oscillator in high gain mode *///            | MCGC2_EREFS_MASK          /* because crystal is being used *///            | MCGC2_RANGE_MASK          /* 12 MHz is in high freq range *///            | MCGC2_ERCLKEN_MASK;       /* activate external reference clock */    MCGC2 = 0x36;    while (MCGSC_OSCINIT == 0)    ///<- system will be blocked in here    ;    /* select clock mode */    MCGC1 = (2<<6)                      /* CLKS = 10 -> external reference clock. */            |(2<<3);                    /* RDIV = 2 ->  8MHz/4=2.0 MHz */    /* wait for mode change to be done */    while (MCGSC_IREFST != 0)    ;    while (MCGSC_CLKST != 2) ;    /* switch from FBE to PBE (PLL bypassed internal) mode */    MCGC3=MCGC3_PLLS_MASK          | (6<<0);     /* VDIV=6 -> multiply by 24 -> 2.0MHz * 24 = 48MHz */    while(MCGSC_PLLST != 1)    ;    while(MCGSC_LOCK != 1)    ;    /* finally switch from PBE to PEE (PLL enabled external mode) */    MCGC1 = (0<<6)         /* CLKS = 0 -> PLL or FLL output clock. */            | (2<<3);      /* RDIV = 2 -> 8MHz/4=2.0 MHz */    while(MCGSC_CLKST!=3) ;    /* Now MCGOUT=48MHz, BUS_CLOCK=24MHz */}

 System will be blocked in 

while (MCGSC_OSCINIT == 0)    ///<- system will be blocked in here

 

How do I solve this problem? Does anyone can give any advice? Thanks a lot.

 

 

Regards,

Pogo

Outcomes