cancel
Showing results for 
Search instead for 
Did you mean: 

Master Clock Out (MCO)

charles2399
Associate II
Posted on January 28, 2009 at 13:16

Master Clock Out (MCO)

5 REPLIES 5
charles2399
Associate II
Posted on May 17, 2011 at 12:56

The Cortex m3 documentation implies that the MCO can be output on the cooresponding GPIO pin. I can not find any reference to the MCO alternate output in RM0008.

Does anyone know how to output MCO on to a GPIO pin? :-?

johnspeth9
Associate II
Posted on May 17, 2011 at 12:56

MCO output is controlled from the RCC_CFGR register along with assigning the appropriate GPIO pin for alt func out.

Here's how I did it using the ST FW lib on the ST3210E-EVAL board from ST:

// Put the system clock on the MCO pin

GPIO_InitTypeDef GPIO_InitStructure;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_Init(GPIOA,&GPIO_InitStructure);

RCC_MCOConfig(RCC_MCO_SYSCLK);

You would execute those lines after the clocks are configured. Don't forget to turn on the GPIO bus clock.

JJS

jaroslaw2
Associate II
Posted on May 17, 2011 at 12:56

Can somebody help me to set MCO exactly at 12.288 Mhz (Pin PA8). I have a problem with starting I2S external codec (PCM3003 by TI).

I couldn't find it in I2S_codec source files provided by STM.

Maybe another nice method for setting master clock for external codec.

sofiene
Associate III
Posted on May 17, 2011 at 12:56

Hi jaroslaw.oska;

I don't know what's the accuracy value of the I2S clock. Did you try the HSI clock? you can tune your frequency by around 40Khz this by configuring the HSITRIM bits in RCC_CR register. There are 32 different values of HSI frequency. You can try different values of PLL mul/div values to have your I2S clock.

B.R.

M3allem

tberk1
Associate II
Posted on May 17, 2011 at 12:56

Like m3allem suggested you could trim the internal clock & multiply by 2 in the PLL to get approximately this value, my worry with temperature fluxuations and inaccuracy of the internal clock you won't get as close as you may need.

There are 12.228 or 3.072Mhz & 4.096Mhz crystals which will produce the required frequency with the PLL. Remember MCO output is PLL/2.

John.Speth code should work.

Todd