How do I get the STM32F103C8T6 to read frequencies from 1Hz to 100KHz correctly and accurately onTIM
How do I get the STM32F103C8T6 to read frequencies from 1Hz to 100Khz correctly and accurately on TIM3?
I set HCLK in the program at 72Mhz, Prescaler at 2999 and Period at 65536.
htim3.Instance = TIM3;
htim3.Init.Prescaler = 2999;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 65535;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
and the program can read the 1Hz frequency correctly but when reading the 1KHz frequency, the value displayed by the program output becomes 1090Hz.
I use the following formula to get the value for the output frequency:

The value of IC_direct_mode_periode is obtained from this section:
![]()
What is the correct prescaler, period or HCLK value so that the program can read frequencies correctly and accurately up to 100Khz?
or is the formula I used to get the value for the output frequency wrong?
