General-purpose timers (TIM)
ï€ Autoreload value = 0xFFFF
ï€ Prescaler value = 0x0000
ï€ Counter mode = Up counting
ï€ Clock Division = TIM_CKD_DIV1
4. Fill the TIM_ICInitStruct with the desired parameters including:
ï€ TIM Channel: TIM_Channel
ï€ TIM Input Capture polarity: TIM_ICPolarity
ï€ TIM Input Capture selection: TIM_ICSelection
ï€ TIM Input Capture Prescaler: TIM_ICPrescaler
ï€ TIM Input CApture filter value: TIM_ICFilter
5. Call TIM_ICInit(TIMx, &TIM_ICInitStruct) to configure the desired channel with the
corresponding configuration and to measure only frequency or duty cycle of the input
signal, or, Call TIM_PWMIConfig(TIMx, &TIM_ICInitStruct) to configure the desired
channels with the corresponding configuration and to measure the frequency and the
duty cycle of the input signal
6. Enable the NVIC or the DMA to read the measured frequency.
7. Enable the corresponding interrupt (or DMA request) to read the Captured value,
using the function TIM_ITConfig(TIMx, TIM_IT_CCx) (or TIM_DMA_Cmd(TIMx,
TIM_DMA_CCx))
8. Call the TIM_Cmd(ENABLE) function to enable the TIM counter.
9. Use TIM_GetCapturex(TIMx); to read the captured value.
All other functions can be used separately to modify, if needed, a specific feature
of the Timer.
ï‚· TIM_ICInit()
ï‚· TIM_ICStructInit()
ï‚· TIM_PWMIConfig()
ï‚· TIM_GetCapture1()
ï‚· TIM_GetCapture2()
ï‚· TIM_GetCapture3()
ï‚· TIM_GetCapture4()
ï‚· TIM_SetIC1Prescaler()
ï‚· TIM_SetIC2Prescaler()
ï‚· TIM_SetIC3Prescaler()
ï‚· TIM_SetIC4Prescaler()
22.2.5 Advanced-control timers (TIM1 and TIM8) specific features
TIM Driver: how to use the Break feature
After configuring the Timer channel(s) in the appropriate Output Compare mode:
1. Fill the TIM_BDTRInitStruct with the desired parameters for the Timer Break Polarity,
dead time, Lock level, the OSSI/OSSR State and the AOE(automatic output enable).
2. Call TIM_BDTRConfig(TIMx, &TIM_BDTRInitStruct) to configure the Timer
3. Enable the Main Output using TIM_CtrlPWMOutputs(TIM1, ENABLE)
4. Once the break even occurs, the Timer's output signals are put in reset state or in a
known state (according to the configuration made in TIM_BDTRConfig() function).
ï‚· TIM_BDTRConfig()
ï‚· TIM_Break1Config()