cancel
Showing results for 
Search instead for 
Did you mean: 

High precision 1Hz resolution Timer on STM32F030K6T6

Aalex.1
Associate II

Hello,

I know that it is possible to cross series two timers to achieve high resolution one. In my case, 32bit resolution is enough. As a result, I would use TIM1 and TIM3 in STM32F030K6T6 to reach desired high resolution frequency generator. Unfortunately it is a little confusing for me to cascading these two timers for 100001Hz Frequency when MCU clock is working at 48MHz. Can anyone help me regarding configuring stm32cube for my purpose.

Thanks advanced.

13 REPLIES 13
Piranha
Chief II

For a digital signal with basic timer you cannot achieve such a frequency resolution. At 48 MHz 480 ticks give you exactly 100 kHz but 479 ticks give 100 209 Hz.

Aalex.1
Associate II

in STM32 cross-series timer overview the possibility is proven but I cannot configure internals interrupts. Please help me.

Piranha
Chief II

You have misunderstood something. You can make lower frequencies with a better frequency resolution, but you cannot make 100'001 Hz.

Aalex.1
Associate II

If possible to divide clock by more than 16bit 48MHz/479995=100.001. And after that if I count to 1000, I will get the precision that is required. What is wrong with this assumption?

Can't you just split the 48 MHz down using the prescaler and period

ie 48000 and 1000 or 4800 and 10000, or some other pair of factors that each fit in 16-bit ?

Prescaler = 4800 - 1;

Period = 10000 - 1;

Or are you trying to count 1 Hz ticks?

Where is 100001 Hz coming into this

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

If you count to 1000, you will lower the input freq by a factor of 1000, i.e. you end up at ca. 0.100001 Hz.

I need to design a clock source which is vary from 10KHz to 150KHz and required resolution is 1Hz.

You are right I forgot about "-1".

You can't achieve this by dividing from a given frequency source. In other words, you can't do this simply by setting up timer in STM32.

JW