...
This application note explains how to use the STM32H7 PWM in the FreeRTOS demo application.
1. Understanding PWM Interfaces
1.1. FreeRTOS PWM Implementation
The FreeRTOS BSP make uses of the STM32CubeH7 software component to provide a device driver for the STM32H7 PWM. 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 PWM C-Binding API
The PWM driver implements the following C-binding API:
...
Code Block |
---|
typedef struct { uint32_t OCMode; /* Specifies the TIM mode. */ uint32_t Pulse; /* Specifies the pulse value to be loaded into the Capture Compare Register. */ uint32_t OCPolarity; /* Specifies the output polarity. */ uint32_t OCNPolarity; /* Specifies the complementary output polarity. */ uint32_t OCFastMode; /* Specifies the Fast mode state. */ uint32_t OCIdleState; /* Specifies the TIM Output Compare pin state during Idle state. */ uint32_t OCNIdleState; /* Specifies the TIM Output Compare pin state during Idle state. */ } TIM_OC_InitTypeDef; |
2. PWM CLI Command
The FreeRTOS application implements the following PWM related CLI command:
Command | Description | Comments |
| Start a PWM output signal | M is the timer number, |
| Stop a PWM output |
|
3. Validating PWM Operation
Use the following step-wise procedure to validate the FreeRTOS PWM operation:
...