Jump to main content

##

# 3.36.7 Digital-to-Analog Converter (DAC)

The Digital-to-Analog Converter (DAC) peripheral provides the following features:

- Up to two single-ended analog outputs or one differential analog output

- 12-bit resolution

- Interpolation mode and Dithering mode

## Using The Library

The DAC peripheral library provides an interface for the conversion of digital values to analog voltage.

The DAC starts conversion when a new data is loaded into a Data register. The resulting voltage is available on the DAC output after the conversion time.

The user must ensure that new data is not written to the DAC before the last conversion is complete as illustrated below.

    // Write new data if DAC is ready
     if (DAC_IsReady(DAC_CHANNEL_0))
     {
        DAC_DataWrite (DAC_CHANNEL_0, 0xff)
     }

## Library Interface

Digital-to-Analog Converter peripheral library provides the following interfaces:

Functions

Name | Description
--- | ---
DAC_Initialize | Initializes DAC module of the device
DAC_DataWrite | Converts a Digital data to Analog value
DAC_IsReady | Returns the status of readiness of Channel of DAC module for new conversion request
DAC_Channel0ResultGet | Returns the Channel 0 Filter output
DAC_Channel1ResultGet | Returns the Channel 1 Filter output

Data types and constants

Name | Type | Description
--- | --- | ---
DAC_CHANNEL_NUM | Enum | Identifies the Channel index of DAC module