AnsweredAssumed Answered

Timers timing thorough explanation, please...

Question asked by martinu.jiri on Apr 22, 2013
Latest reply on Apr 23, 2013 by martinu.jiri
Hi all,

I know it was disscused many times over the forum but still I can't get the correct results for the timer setting in PWM mode...

Can someone explain to me step by step how to understand timers timing, please?

I've used the clock configuration tool for STM32F4xx from ST.

The only thing I've changed was the HSE value from 25 to 8MHz as the STM32f4 Discovery board is fitted by the 8MHz quartz.

Now, the clock configuration is (based on the values indicated by the config tool):

AHBx Prescaler: 4
HCLK frequency: 16MHz
APB1Prescaler: 1
TIM 2, 3, 4, 5, 6, 7, 12, 13, 14: 16MHz
TIM 1, 8, 9, 10, 11: 16MHz
PCLK1: 42MHz max, 16MHz
PCLK2: 84MHz max, 16MHz
Enable I2S Clock: checked as I need to communicate with the LIS302DL MEMS on the board

How I have to set the timing TIM1, TIM2 and TIM3 clock if I want to get:

a) 20ms period PWM output with duty cycle from 1 - 2 ms (for servo control)
b) input capture in period of 500 ms
c) input capture in period of 100 ms?

Teach me, please, step by step, what to do to get expected values from timers.

What value for timer prescaler and why?
What value for timer period and why?
What value for clock division and why?

Is the calculating same for all timers providing the above mentioned clock settings (by the clock configuration tool)?

My servo control was working well before I exchanged the file generated by the clock configuration tool (the settings was from some example found web). Now, it doesn't work anymore and anyway I would like to understand how to set the timers timing correctly for the case I'll change the Discovery board for something different (with the same STM32F407 microcontroler, of course) in future.

Thank you all for your answers in advance... I thing that it'll be useful for many folks here :-)