How do I set Coldfire V1 MCG registers properly ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I set Coldfire V1 MCG registers properly ?

618 Views
bob2
Contributor I

I have a 4MHz external crystal and want the CPUCLOCK = 32MHz and BUSCLOCK = 16MHz so both the SCI and RTC can use the bus clock for timing.

Labels (1)
Tags (1)
0 Kudos
3 Replies

413 Views
TomE
Specialist II

Which CPU model, exactly.

I've got the MCF51EM256 manual open, and a search for "MCG" (which means "Melbourne Cricket Ground" to me :-) doesn't find anything.

If you've tried to program it and are having trouble, post a section of your code and what you're measuring.

Tom

0 Kudos

413 Views
bob2
Contributor I

Tom Evans,

Thanks for responding to my question.

Given the following:

Processor: MCF51JM128EVLK

Desired Reference clock: 4MHz external crystal

When set correctly, the CPU clock frequency will be 32MHz and the BUS clock will be 16MHz.

My question is this

I believe I need to change the clock settings from FEI mode which uses the internal reference clock;

To FEE mode which uses the external crystal oscillator.

Please tell me what values to load into the MCG module registers:

MCGC1, MCGC2, MCGC3, MCGC4, etc. and

Please tell me the sequence, ie: which register to load: 1st, 2nd, 3rd, etc.

Also indicate if I need to read, write, or pause until certain bits are set in the MCGSC ( Status / Control ).

Lastly, tell me what effect my debugging using the PE Micro BDM interface will have on these clock

Settings.

Thankyou for your help ! Have a super day !

Bob Reichenbach bob@minimusspine.com

Minimus Spine, Inc.

Austin, TX. 78750

0 Kudos

413 Views
scottm
Senior Contributor II

Hi Bob,

Here's a snippet from an old JM128 project of mine:

// Clock generator setup - external 12 MHz reference crystal, 48 MHz PLL
// MCGOUT must be 48 MHz for USB operation (PLL engaged external)
// 12 MHz / 8 = 1.5 MHz, * 32 = 48 MHz
MCGC2 = 0x36;     // High range, high gain, osc on, MCGERCLK active, BDIV=1
while ((MCGSC & 2) == 0);
MCGC1 = 0b10011000; // External reference, RDIV=8
while ((MCGSC & 0x10) != 0);
while ((MCGSC & 0x0c) != 0x08);
MCGC3 = 0x48; // PLL selected, VDIV=32
while ((MCGSC & 0x20) == 0);
while ((MCGSC & 0x40) == 0);
MCGC1 = 0b00011000; // Switch to PLL, RDIV=8 

This was set up for a 12 MHz reference crystal and produces a 48 MHz bus clock, so it should give you your 16 MHz bus clock from 4 MHz.

If you're using CodeWarrior, I'd suggest checking the Processor Expert tool.  It does a pretty good job on ColdFire.  Even if you don't want to use PE in your project, you can create a dummy project and use the clock configuration tool to generate code you can reference.

I've got a couple of P&E Cyclone PROs and a couple of Multilink BDMs and they haven't needed any special setup.

Hope that helps,

Scott

0 Kudos