Jump to content
Sign in to follow this  
Rickta59

Output MCO on GPIOA.8 - STM32F0

Recommended Posts

I wanted to be able to verify my system clock was configured properly. I found this feature very useful on the msp430 chips. Turns out that the STM32 Cortex M0 chips also support this. Attached is some code that allows you to output your SYSCLK on pin PA.8 for easy verification of your various clock sources.

 


/**
* Cortex M0 - STM32F0 Discovery board code spew out one of the clocks on PA.8
*/
void OutputMCO() {
GPIO_InitTypeDef GPIO_InitStructure;

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

/* Output clock on MCO pin ---------------------------------------------*/

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);

// pick one of the clocks to spew
RCC_MCOConfig(RCC_MCOSource_SYSCLK); // Put on MCO pin the: System clock selected
//RCC_MCOConfig(RCC_MCOSource_HSE); // Put on MCO pin the: freq. of external crystal
//RCC_MCOConfig(RCC_MCOSource_PLLCLK_Div2); // Put on MCO pin the: System clock selected
}

 

-rick

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×