cancel
Showing results for 
Search instead for 
Did you mean: 

NUCLEO-G0B1RE TIM1 ck_clk and the cpu clock frequencies

kag_embedded
Associate II

I would like to use TIM2 as a performance counter to evaluate my software changes. 

Is the TIM2 internal clock 1/4 of the CPU clock on the NUCLEO-G0B1RE board? Net effect, resulting in the TIM2 counter having a resolution of four CPU clock cycles.

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions

The system boos up using the HSI as a clock, which is 16 MHz. That certainly agrees with what the timer is telling you. HAL also has functions for retrieving the speed: HAL_RCC_GetHCLKFreq().

 

You can validate clock speeds by routing a signal out to MCO and monitoring it on a scope. Enable MCO in the RCC tab. (Not that there's a reason to doubt what the clock configuration tab is telling you.)

TDK_0-1728356319784.png

 

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

4 REPLIES 4
TDK
Guru

The TIM2 clock is the same as the CPU clock by default.

TDK_0-1728348768629.png

 

If you want it to be 1/4 of the CPU clock, change the prescaler to 3. This will result in a TIM2 clock of HCLK/4 or 4 MHz.

TDK_1-1728348853014.png

 

If you feel a post has answered your question, please click "Accept as Solution".

How can I validate my CPU clock frequency? I have been assuming that my CPU would be booting up to 64MHz.

After reset, I clear and start TIM2 and then delay HAL_Delay(1000) for 1 second.  The count is 16M indicating that the timer frequency is 1/4 of 64MHz or the CPU clock is 16MHz. The TIM2 prescalar register is 0x0 indicating a divide by 1.

The system boos up using the HSI as a clock, which is 16 MHz. That certainly agrees with what the timer is telling you. HAL also has functions for retrieving the speed: HAL_RCC_GetHCLKFreq().

 

You can validate clock speeds by routing a signal out to MCO and monitoring it on a scope. Enable MCO in the RCC tab. (Not that there's a reason to doubt what the clock configuration tab is telling you.)

TDK_0-1728356319784.png

 

If you feel a post has answered your question, please click "Accept as Solution".
kag_embedded
Associate II

Thank you.