Jump to main content

##

# 3.43.4 Digital-to-Analog Converter (DAC)

The Digital-to-Analog Converter (DAC) converts a digital value to a voltage. The DAC Controller controls two DACs, which can operate either as two independent DACs or as a single DAC in differential mode. Each DAC is 12-bit resolution and it is capable of converting up to 1,000,000 samples per second (MSPS).

The DAC peripheral provides the following features:

- Two independent DACs or single DAC in differential mode

- DAC with 12-bit resolution

- Up to 1MSPS conversion rate

- Hardware support for 16-bit using dithering

- Multiple trigger sources

- High-drive capabilities

- DAC0 used as internal input

- DMA support

## Using The Library

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

Data types and constants

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