Versions Compared

Key

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

...

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

1. Understanding ADC Interfaces

1.1. FreeRTOS ADC Implementation

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

1.2. FreeRTOS ADC C-Binding API

The ADC driver implements the following C-binding API:

...

Code Block
typedef struct
{
  uint32_t Channel;                       /* Specify the channel to configure 
                                             into ADC regular group. */
  uint32_t Rank;                          /* Specify the rank in the regular 
                                             group sequencer. */
  uint32_t SamplingTime;                  /* Sampling time value to be set for 
                                             the selected channel. */
  uint32_t SingleDiff;                    /* Select single-ended or differential
                                             input. */
  uint32_t OffsetNumber;                  /* Select the offset number. */
  uint32_t Offset;                        /* Define the offset to be subtracted 
                                             from the raw converted data. */
  FunctionalState OffsetRightShift;       /* Define the Right-shift data 
                                             after Offset correction. */
  FunctionalState OffsetSignedSaturation; /* Specify whether the Signed 
                                             saturation feature is used or not.*/
} ADC_ChannelConfTypeDef;

2. ADC CLI Command

The FreeRTOS application implements the following ADC related CLI command:

Command

Description

Comments

adc_se<nadc> <chnl>

Run the ADC test in the single-ended input mode

nadc is the ADC number, chnl is the channel number

3. Validating ADC Operation

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

...