2020-07-15 05:24 AM
I found from ref manual that the internal clock source for TIM1 is APB2 pre-scaled value.
(Please see attached image).
From CubeMx, I've configured my main clock frequency to be 48MHz, which is a PLL multiplied value from external crystal oscillator of 8MHz.
(Please see second attached image)
With these in mind, I was trying to get a 1ms timer tick by configuring the timer as below:
(please see third attached image)
But when I measured the clock period on an oscilloscope, I found it to be 2ms and NOT 1ms.
This showed that the internal clock input to TIM1 is being taken as 24MHz, and not 48MHz
(I confirmed this by adjusting the pre-scalar to 24000).
So what exactly is the clock input source for TIM1?
Few other points -
I've absolutely made no timer configuration changes in the code.
I was able to get calculated timer period of 1ms on TIM3, which seems to be fed with 48MHz clock input.
Solved! Go to Solution.
2020-07-16 11:41 PM
fclock is 48 MHz and you see 2 ms because you set ARR=1, Time Period = ((PSC+1)*(ARR+1))/FClock in Second in your case ((48000+1)*(1+1))/48000000 almost equal to 2 Ms.
2020-07-15 06:01 AM
Timer period is 1/fclock*(PSC+1)*(ARR+1).
JW
2020-07-15 09:36 PM
Hello JW,
Thanks for the response,
but I just need to know what is the input clock source which is selected as default for TIM1?
Is it APB2 peripheral clock or APB2 timer clock?
From my observations, it seems to be APB2 peripheral clock (24MHz in my case), but the documentation says it is APB2 timer clock (48MHz in my case).
2020-07-16 11:41 PM
fclock is 48 MHz and you see 2 ms because you set ARR=1, Time Period = ((PSC+1)*(ARR+1))/FClock in Second in your case ((48000+1)*(1+1))/48000000 almost equal to 2 Ms.
2020-07-20 03:36 AM
Oh
Thanks a lot for bringing out my mistake.
With this formula, I was able to get a 1ms timer period.
I tried achieving 1us, but I guess the timer doesn't go beyond 7us.
Anyway, I'll ask this query in a different post.
Thanks Msd.1