cancel
Showing results for 
Search instead for 
Did you mean: 

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

ledi001
Senior

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Mike_ST
ST Employee

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)

View solution in original post

3 REPLIES 3

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
ST Employee

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)

ledi001
Senior

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

Thank you!