AnsweredAssumed Answered

MCF51MM256 - the OSCINIT bit of the Multipurpose Clock Generator is never set

Question asked by Steve Leatherland on Apr 8, 2011
Latest reply on Apr 20, 2011 by Steve Leatherland

Hello,

 

I am using an MCF51MM device on a custom PCB that is based very closely on the schematic of the TWR-MCF51MM development kit.   I have been unable to get beyond a specific point in the configuration of the Multipurpose Clock Generator (MCG), specifically where the program waits indefinately for the OSCINIT bit in the MCGSC register to be set.  However, if I run the exact same code on the microcontroller in the TWR-MCF51MM board there is no problem at all.

 

My application is using MQX and I have identified the specific point where the code gets stuck to be in the module "bsp_init.c" , the third line in the function _mqx_clock_init_16MHz().  See below:

 

static void _mqx_clock_init_16MHz()
{
    VMCF51MM_MCG_STRUCT_PTR mcg_ptr =
        (VMCF51MM_MCG_STRUCT_PTR)&(((VMCF51MM_STRUCT_PTR)BSP_IPSBAR)->MCG);

    /*
    ** ------FBE MODE------  
    ** Assume 16MHz external clock source connected.
    ** RANGE = 1; HGO = 1; ERCLKEN=1; EREFS = 1; BDIV = 00
    */

    mcg_ptr->MCGC2 =  MCF51XX_MCGC2_RANGE_MASK
                    | MCF51XX_MCGC2_HGO_MASK
                    | MCF51XX_MCGC2_ERCLKEN_MASK
                    | MCF51XX_MCGC2_EREFS_MASK;

    /*
    ** Loop until OSCINIT (bit 1) in MCGSC is 1,
    ** indicating the crystal selected
    ** by the EREFS bit has been initialized.
    */
//    while( ! mcg_ptr->MCGSC & MCF51XX_MCGSC_OSCINIT_MASK );
    while( !(mcg_ptr->MCGSC & MCF51XX_MCGSC_OSCINIT_MASK) ){};    // STEVE: repaired operator precedence bug in BSP

.

.

.

 

(Note that there was a bug that line, which at first I was sure must be the cause of this problem, but unfortunately it appears not to be).

 

I have pretty much ruled out the possibility that the 16MHz crystal is the problem because on my custom board the microcontroller's ROM based USB bootloader functions properly and in fact I can see that when the bootloader is running the oscillator is working fine.

 

I have checked the header file which defines the masks used in the code above and they are correct according to the datasheet.  In a debugger I have also watched the MCGC2 and MCGSC registers and they appear to be correct.

 

The only difference that I can see is that the microcontrollers on my custom board are part number MCF51MM256VLL while the one on the development board is a PCF51MM256VLL (i.e. it has a Product Development code).

 

Does anyone have any ideas on what might be the cause of this?

 

Thank you.

Outcomes