HAL DAC Overview ¶
Introducing DAC ¶
- group DAC_Introduction
-
The DAC (Digital-to-Analog Converter) hardware abstraction layer provides a set of APIs to interface with the STM32 DAC peripheral.
It simplifies the configuration, initialization, and management of analog output functionality, supporting various modes such as polling, interrupt, and DMA for efficient data transfer.
This abstraction layer ensures portability and ease of use across different STM32 series. The HAL DAC driver abstracts device-specific features.
The HAL DAC driver includes the following features:
Output buffer management for driving external loads
Calibration features for improved analog output accuracy
Support for single and dual-channel operation
Advanced signal generation:
Noise
Triangle
User-defined buffer transfer via DMA
Sample-and-hold mode for low-power applications
Module and files ¶
The following diagram illustrates the DAC module and its associated files.
Component diagram ¶
The following diagram illustrates the software components involved in the DAC 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 DAC module, specifying their locations, default values, and descriptions:
- group DAC_Configuration_Table
-
Configuration in the DAC driver ¶
Config defines
Description
Default value
Note
USE_HAL_DAC_MODULE
hal_conf.h
1
HAL DAC module is enabled.
USE_HAL_DAC_USER_DATA
hal_conf.h
0
Enable user data.
USE_HAL_DAC_REGISTER_CALLBACKS
hal_conf.h
0
Enable register callback assertions.
USE_HAL_DAC_CLK_ENABLE_MODEL
hal_conf.h
HAL_CLK_ENABLE_NO
Otherwise, the clock is enabled inside HAL_DAC_Init().
USE_HAL_DAC_DMA
hal_conf.h
1
Use DMA with the DAC.
USE_HAL_CHECK_PARAM
hal_conf.h
0
Enable run-time checks on function parameters.
USE_HAL_CHECK_PROCESS_STATE
hal_conf.h
0
Enable run-time checks on the state during processing.
USE_HAL_DAC_GET_LAST_ERRORS
hal_conf.h
0
Record errors that occur during DAC channel processing.
USE_HAL_DAC_DUAL_CHANNEL
hal_conf.h
1
Enable DAC dual channel mode (if DAC_NB_OF_CHANNEL > 1).
USE_ASSERT_DBG_PARAM
Pre-processor env
None
Enable assert checks on function parameters.
USE_ASSERT_DBG_STATE
Pre-processor env
None
Enable assert checks on module state.
DAC_NB_OF_CHANNEL
DFP
NA
DAC channel count (value “2” allows dual mode).