Hardware Abstraction Layer (HAL)
DAC (Digital to Analog Converter)

Power Level Mapping

The following table shows how the HAL-defined power levels map to the hardware-specific power levels when cyhal_dac uses output pin buffered mode (with opamp). Unbuffered mode only supports ON and OFF.

HAL Power Level Opamp Power Level
CYHAL_POWER_LEVEL_HIGH CY_CTB_POWER_HIGH
CYHAL_POWER_LEVEL_MEDIUM CY_CTB_POWER_MEDIUM
CYHAL_POWER_LEVEL_LOW CY_CTB_POWER_LOW
CYHAL_POWER_LEVEL_DEFAULT CY_CTB_POWER_MEDIUM

cyhal_dac automatically choose between buffered and unbuffered mode by selecting pin. Unbuffered mode - dac pin, buffered - opamp pin. Buffered mode take care of reserving and configuring the opamp (OA0). If AREF voltage reference source is selected cyhal_dac takes care of reserving and configuring the opamp (OA1). By default cyhal_dac use VDDA voltage reference source. Use cyhal_dac_set_reference() to change between CYHAL_DAC_REF_VDDA and CYHAL_DAC_REF_VREF voltage reference sources.

Note
When initializing the DAC via cyhal_dac_init_cfg, if opamps are required (either for buffered output or for buffering the AREF output when CYHAL_DAC_REF_VREF is used) then they must be separately configured via cyhal_opamp_init_cfg before the DAC is initialized. However, once the DAC is initialized, the cyhal_dac_set_power function will update the power mode for the opamp(s) in the same manner that it does for DAC instances initialized via cyhal_dac_init.
When the DAC has been initialized via cyhal_dac_init_cfg, the cyhal_dac_set_reference function is not supported and will return CYHAL_DAC_RSLT_INVALID_CONFIGURATOR. This is because the cyhal_dac_set_reference function needs to manipulate the configuration and routing for OA1, and in this scenario that configuration and routing is owned by the configurator.