Skip to main content
ledi001
Associate III
March 19, 2021
Solved

how to i route the internal HSI16 clock to MCO pin of STM32G071?

  • March 19, 2021
  • 3 replies
  • 1970 views

hello,

i use a NUCLEO-G071RB board and want to route the internal HSI16 clock to MCO pin (Pin12).

First i created a board project with CubeMX and aktivated the MCO pin. Then i set HSI16 as default clock and routed the clock signal to MCO pin. After code generation and starting the programm i cant measure a signal on MCO pin.

This topic has been closed for replies.
Best answer by Mike_ST

There is that RCC function that you may want to call:

/**

 * @brief Select the clock source to output on MCO pin(PA8).

 * @note  PA8 should be configured in alternate function mode.

 * @param RCC_MCOx specifies the output direction for the clock source.

 *         For STM32G0xx family this parameter can have only one value:

 *           @arg @ref RCC_MCO1 Clock source to output on MCO1 pin(PA8).

 * @param RCC_MCOSource specifies the clock source to output.

 *         This parameter can be one of the following values:

 *           @arg @ref RCC_MCO1SOURCE_NOCLOCK MCO output disabled, no clock on MCO

 *           @arg @ref RCC_MCO1SOURCE_SYSCLK system clock selected as MCO source

 *           @arg @ref RCC_MCO1SOURCE_HSI HSI clock selected as MCO source

 *           @arg @ref RCC_MCO1SOURCE_HSE HSE clock selected as MCO sourcee

 *           @arg @ref RCC_MCO1SOURCE_PLLCLK main PLL clock selected as MCO source

 *           @arg @ref RCC_MCO1SOURCE_LSI LSI clock selected as MCO source

 *           @arg @ref RCC_MCO1SOURCE_LSE LSE clock selected as MCO source

 * @param RCC_MCODiv specifies the MCO prescaler.

 *         This parameter can be one of the following values:

 *           @arg @ref RCC_MCODIV_1 no division applied to MCO clock

 *           @arg @ref RCC_MCODIV_2 division by 2 applied to MCO clock

 *           @arg @ref RCC_MCODIV_4 division by 4 applied to MCO clock

 *           @arg @ref RCC_MCODIV_8 division by 8 applied to MCO clock

 *           @arg @ref RCC_MCODIV_16 division by 16 applied to MCO clock

 *           @arg @ref RCC_MCODIV_32 division by 32 applied to MCO clock

 *           @arg @ref RCC_MCODIV_64 division by 64 applied to MCO clock

 *           @arg @ref RCC_MCODIV_128 division by 128 applied to MCO clock

 * @retval None

 */

void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv)

3 replies

waclawek.jan
Super User
March 19, 2021

Read out and check the respective RCC registers (RCC_CFGR), and check in respectrive GPIO_MODER if the given pin is set to AF, and GPIO_AFR if the given pin's AF number is set appropriately for MCO (see pins AF table in datasheet).

JW

Mike_ST
Mike_STBest answer
ST Technical Moderator
March 19, 2021

There is that RCC function that you may want to call:

/**

 * @brief Select the clock source to output on MCO pin(PA8).

 * @note  PA8 should be configured in alternate function mode.

 * @param RCC_MCOx specifies the output direction for the clock source.

 *         For STM32G0xx family this parameter can have only one value:

 *           @arg @ref RCC_MCO1 Clock source to output on MCO1 pin(PA8).

 * @param RCC_MCOSource specifies the clock source to output.

 *         This parameter can be one of the following values:

 *           @arg @ref RCC_MCO1SOURCE_NOCLOCK MCO output disabled, no clock on MCO

 *           @arg @ref RCC_MCO1SOURCE_SYSCLK system clock selected as MCO source

 *           @arg @ref RCC_MCO1SOURCE_HSI HSI clock selected as MCO source

 *           @arg @ref RCC_MCO1SOURCE_HSE HSE clock selected as MCO sourcee

 *           @arg @ref RCC_MCO1SOURCE_PLLCLK main PLL clock selected as MCO source

 *           @arg @ref RCC_MCO1SOURCE_LSI LSI clock selected as MCO source

 *           @arg @ref RCC_MCO1SOURCE_LSE LSE clock selected as MCO source

 * @param RCC_MCODiv specifies the MCO prescaler.

 *         This parameter can be one of the following values:

 *           @arg @ref RCC_MCODIV_1 no division applied to MCO clock

 *           @arg @ref RCC_MCODIV_2 division by 2 applied to MCO clock

 *           @arg @ref RCC_MCODIV_4 division by 4 applied to MCO clock

 *           @arg @ref RCC_MCODIV_8 division by 8 applied to MCO clock

 *           @arg @ref RCC_MCODIV_16 division by 16 applied to MCO clock

 *           @arg @ref RCC_MCODIV_32 division by 32 applied to MCO clock

 *           @arg @ref RCC_MCODIV_64 division by 64 applied to MCO clock

 *           @arg @ref RCC_MCODIV_128 division by 128 applied to MCO clock

 * @retval None

 */

void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv)

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. 
ledi001
ledi001Author
Associate III
March 19, 2021

oh, it is pin PA8...now it works!

Thank you!