cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32f103 MCO output

paul sauv
Associate III
Posted on September 10, 2017 at 18:00

I try to configure my MCO ouput on my STM32f103, only with STD periph lib.

here is my code:

 void OutputMCO() { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); /* Output clock on MCO pin ---------------------------------------------*/ 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); // 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 }

I have an issue here:

// 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

None of the 3 possibilities are working on my code. This code was found on internet. Do you know where should I find correct parameters ? The definition of RCC_MCOSource doesn't really help me

Thank you

#stm32f103 #mco #stm32-mco-clock-output
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on September 10, 2017 at 20:41

STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Examples\RCC\RCC_ClockConfig\main.c

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

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

  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_HSE);
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

1 REPLY 1
Posted on September 10, 2017 at 20:41

STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Examples\RCC\RCC_ClockConfig\main.c

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

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

  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_HSE);
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..