3.32.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

NameDescription
DAC_InitializeInitializes DAC module of the device
DAC_DataWriteConverts a Digital data to Analog value
DAC_IsReadyReturns the status of readiness of Channel of DAC module for new conversion request
DAC_Channel0ResultGetReturns the Channel 0 Filter output
DAC_Channel1ResultGetReturns the Channel 1 Filter output

Data types and constants

NameTypeDescription
DAC_CHANNEL_NUMEnumIdentifies the Channel index of DAC module