Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This application note explains how to use the STM32H7 timers in the FreeRTOS demo application.

1. Understanding Timer Interfaces

1.1. FreeRTOS Timers Implementation

The FreeRTOS BSP makes use of the STM32CubeH7 software component to provide a device driver for the STM32H7 general-purpose timers. The driver is configured (enabled / disabled) at the BSP build time, using the HAL_TIM_MODULE_ENABLED configuration option, defined in the stm32h7xx_hal_conf.h file.

1.2. FreeRTOS Timers C-Binding API

The Timers driver implements the following C-binding API:

...

Code Block
typedef struct
{
  uint32_t Prescaler;         /* Specifies the prescaler value used to divide the 
                                 TIM clock. */
  uint32_t CounterMode;       /* Specifies the counter mode. */
  uint32_t Period;            /* Specifies the period value to be loaded into 
                                 the active Auto-Reload Register at the next 
                                 update event. */
  uint32_t ClockDivision;     /* Specifies the clock division. */
  uint32_t RepetitionCounter; /* Specifies the repetition counter value. */
  uint32_t AutoReloadPreload; /* Specifies the auto-reload preload. */
} TIM_Base_InitTypeDef;

1.3. FreeRTOS Timers Task

The FreeRTOS demo application implements a separate thread (called "Timers Thread") illustrating use of the general-purpose timers API from a FreeRTOS application. Namely, the timers thread implements counting number of interrupts from the TIM7 timer. TIM7 is configured to generate an interrupt 1000 times per second.

2. Timers CLI Command

The FreeRTOS application implements the following timers related CLI command:

Command

Description

Comments

timer_cnt

Command to output the value of the number interrupts counted by the timers thread

3. Validating Timers Operation

Use the following step-wise procedure to validate the FreeRTOS timers operation:

...