HAL TimeBase TIM Overview

Introducing HAL TimeBase TIM

group TimeBase_TIM_Introduction

  • The TIM time base pattern provides an alternative to the default Cortex System Timer (SysTick) for the HAL time base in STM32 microcontrollers.

  • This is useful in applications where SysTick is reserved for an RTOS, and a hardware timer (TIM) can generate periodic interrupts for the HAL tick.

  • The TIM timebase implementation is ready-to-use, requires no customization, and integrates seamlessly with the STM32 HAL.

Module and files

The following diagram illustrates the HAL TimeBase TIM module and its associated files.

Module and files diagram

Component diagram

The following diagram illustrates the software components involved in the HAL TimeBase TIM module. It shows the interactions between the user application, HAL drivers, low-level drivers, and the hardware components.


@startuml
<style>
componentDiagram {
   arrow {
      FontSize 8
   }
}
</style>

title Timebase TIM Software Component Diagram

package "HAL" {
    [HAL_CORTEX]
    [HAL_RCC]
    [HAL_TIMEBASE_TIM]
    [HAL_TIM]
}

package "Low Layer" {
    [LL_TIM]
    [CMSIS]
    [TIM Interrupt routine service]
}

package "HW" {
    [STM32_HW]
}

[Appli] --> [HAL_TIMEBASE_TIM] : HAL Timebase TIM API
[Appli] <-- [HAL_TIMEBASE_TIM] : TIM callback
[HAL_TIMEBASE_TIM] --> [HAL_TIM] : HAL TIM API
[HAL_TIM] --> [LL_TIM] : LL TIM API
[HAL_TIM] -l-> [CMSIS] : IS_TIM_<FEATURE>_INSTANCE
[HAL_TIMEBASE_TIM] -l-> [HAL_CORTEX] : HAL_CORTEX_NVIC_SetPriority
[HAL_TIM] -l-> [HAL_RCC] : HAL_RCC_TIMx_EnableClock
[HAL_TIM] <-- [TIM Interrupt routine service]
[LL_TIM] --> [CMSIS]:TIM register def
[STM32_HW] -u--> [TIM Interrupt routine service]: TIMx Irq
[STM32_HW] <-- [LL_TIM] : TIM registers R/W
@enduml

Configuration table

The following table lists the configuration defines for the HAL TimeBase TIM, specifying their locations, default values, and descriptions:

group TimeBase_TIM_Configuration_Table

Configuration inside the TIM time base

Config defines

Where

Default value

Note

USE_HAL_TIM_MODULE

hal_conf.h

1

HAL TIM module is enabled

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