HAL TIM Overview ¶
Introducing TIM ¶
- group TIM_Introduction
-
The TIM hardware abstraction layer (HAL) provides a set of APIs to interface with STM32 timers.
STM32 timers (TIM) are used for precise time base generation, pulse width modulation (PWM), and event measurement, such as input capture and output compare. They enable motor control, signal timing, and encoder decoding in embedded systems.
The TIM HAL driver simplifies the configuration, initialization, and management of timer operations by supporting various modes such as polling, interrupt, and DMA, enabling flexible and efficient timer control.
Additionally, it supports multiple timer types (advanced-control, general-purpose, lite, and basic timers) depending on the STM32 device, ensuring portability and consistency across different STM32 series.
Module and files ¶
The following diagram illustrates the TIM module and its associated files.
Component diagram ¶
The following diagram illustrates the software components involved in the TIM module. It shows the interactions between the user application, HAL drivers, low-level drivers, and the hardware components.
Configuration table ¶
The following table lists the configuration defines for the HAL TIM module, specifying their locations, default values, and descriptions:
- group TIM_Configuration_Table
-
Configuration inside the TIM driver ¶
Config defines
Where
Default value
Note
USE_HAL_TIM_MODULE
hal_conf.h
1
HAL TIM module is enabled
USE_HAL_TIM_DMA
hal_conf.h
1
Enable the DMA code inside TIM
USE_HAL_TIM_REGISTER_CALLBACKS
hal_conf.h
0
Enable register callback feature
USE_HAL_TIM_CLK_ENABLE_MODEL
hal_conf.h
HAL_CLK_ENABLE_NO
Enable the gating of the peripheral clock
USE_HAL_CHECK_PARAM
hal_conf.h
0
Enable run-time parameter check
USE_HAL_CHECK_PROCESS_STATE
hal_conf.h
0
Enable atomic access to process state check
USE_ASSERT_DBG_PARAM
PreProcessor env
NA
Enable the parameter assert
USE_ASSERT_DBG_STATE
PreProcessor env
NA
Enable the state assert
USE_HAL_TIM_GET_LAST_ERRORS
hal_conf.h
0
Enable retrieving the error codes
USE_HAL_TIM_USER_DATA
hal_conf.h
0
Add an user data inside HAL TIM handle