HAL TIM Generic Driver
DMA_HandleTypeDef* TIM_HandleTypeDef::hdma[7]
DMA Handlers array This array is accessed by a
HAL_LockTypeDef TIM_HandleTypeDef::Lock
Locking object
__IO HAL_TIM_StateTypeDef TIM_HandleTypeDef::State
TIM operation state
45.2
TIM Firmware driver API description
45.2.1
TIMER Generic features
The Timer features include:
1.
16-bit up, down, up/down auto-reload counter.
2.
16-bit programmable prescaler allowing dividing (also on the fly) the counter clock
frequency either by any factor between 1 and 65536.
3.
Up to 4 independent channels for:
45.2.2
How to use this driver
1.
Initialize the TIM low level resources by implementing the following functions
depending from feature used :
2.
Initialize the TIM low level resources :
a.
b.
3.
The external Clock can be configured, if needed (the default clock is the internal clock
from the APBx), using the following function: HAL_TIM_ConfigClockSource, the clock
configuration should be done before any start function.
4.
Configure the TIM in the desired functioning mode using one of the initialization
function of this driver:
5.
Activate the TIM peripheral using one of the start functions depending from the feature
used:
578/1371
Input Capture
Output Compare
PWM generation (Edge and Center-aligned Mode)
One-pulse mode output
Time Base : HAL_TIM_Base_MspInit()
Input Capture : HAL_TIM_IC_MspInit()
Output Compare : HAL_TIM_OC_MspInit()
PWM generation : HAL_TIM_PWM_MspInit()
One-pulse mode output : HAL_TIM_OnePulse_MspInit()
Encoder mode output : HAL_TIM_Encoder_MspInit()
Enable the TIM interface clock using __TIMx_CLK_ENABLE();
TIM pins configuration
Enable the clock for the TIM GPIOs using the following function:
__GPIOx_CLK_ENABLE();
Configure these TIM pins in Alternate function mode using HAL_GPIO_Init();
HAL_TIM_Base_Init: to use the Timer to generate a simple time base
HAL_TIM_OC_Init and HAL_TIM_OC_ConfigChannel: to use the Timer to
generate an Output Compare signal.
HAL_TIM_PWM_Init and HAL_TIM_PWM_ConfigChannel: to use the Timer to
generate a PWM signal.
HAL_TIM_IC_Init and HAL_TIM_IC_ConfigChannel: to use the Timer to measure
an external signal.
HAL_TIM_OnePulse_Init and HAL_TIM_OnePulse_ConfigChannel: to use the
Timer in One Pulse Mode.
HAL_TIM_Encoder_Init: to use the Timer Encoder Interface.
DocID028236 Rev 2
DMA_Handle_index
UM1940
Need help?
Do you have a question about the STM32F2 and is the answer not in the manual?