2014-10-31 02:41 AM
Hello,
I want to make a timer for my software (call a call back when time is finish). I need to understand the clock source for the timer. I choose to work with TIM7 for that (basic timer). As I see, using RCC_GetClocksFreq(&Clock_Info_s), I have some clock on my system.: SYSCLK_Frequency 168000000 HCLK_Frequency 168000000 PCLK1_Frequency 42000000 PCLK2_Frequency 84000000 What is the clock source to be used to calculate the prescaler and period for my timer? By experience I found that the source clock shall be 82.6MHz. The nearest is PCLK2 @84MHz, but with 2% error!! How can I configure my period and prescaler to have a good accuracy (<0.5%)?2014-10-31 06:09 AM
2014-10-31 09:30 AM
What APB is the timer on? Look at the clock tree in the Reference Manual, and observe that TIMCLK is typically x2 except in DIV1 settings.
Also that Period and Prescaler are programmed in N-1 form, and the accuracy of the HSI clock is pretty rough compared to a crystal or TCXO source, or measurement equipment using such. OutputClock = TIMCLK / (P * Q) where Prescaler = P - 1; Period = Q - 1;