2020-11-04 02:19 AM
Hello,
I am trying to program my TIM2 to set an interrupt every 100ms. As seen in the pictured that is attached, its APB runs on 170MHz. Given so, I have set the prescaler to 34000 and the counter to 500.
It has been functioning correctly this whole time.
Recently, I noticed it was behaving in a quite slowly manner. Checking it carefully by toggling an LED every interrupt and measuring with the oscilloscope, I noticed the interrupt arising every 1.06s, which, for the given prescaler and counter values (that I checked and remain the same), indicates it is running on an internal clock of 16MHz. The only one available is HSI RC, which is not even selected on the clock tree.
What might be wrong? Any idea?
Thanks in advance!
Solved! Go to Solution.
2020-11-04 05:37 AM
It boots up with HSI as the clock source. My guess is you didn't change it from that, or your call to change the source to HSE failed.
2020-11-04 05:37 AM
It boots up with HSI as the clock source. My guess is you didn't change it from that, or your call to change the source to HSE failed.
2020-11-04 06:36 AM
You're right! There's a timeout during the HAL_RCC_OscConfig when waiting for RCC_CR_HSERDY bit to be set to 1, which indicates HSE is ready. What might be the cause?
2020-11-04 06:38 AM
Nevermind! I just found out the Crystal is broken. Many, many thanks for the enlightenment!
Kind regards!
2020-11-04 06:42 AM
2020-11-04 06:44 AM
A printf() of SYSCLK/HCLK, APB1, APB2 clock frequencies as perceived by the MCU can save hours of time.