MCUXpresso SDK API Reference Manual  Rev 2.16.000
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
DAC Peripheral and Driver Overview

Content including 1) peripheral features, work logic and work method; 2) driver design logic and use method; 3) typical use case. More...

Peripheral features and how this peripheral works

The 12-bit digital-to-analog converter(DAC) provides a voltage reference to on-chip modules or a package pin. It can also be used as a waveform generator to generate triangle and sawtooth waveforms. The DAC module has two different operation modes, they are Normal Mode and Automatic mode. In the Normal mode, the DAC is used to convert the digital value to analog voltage, the input data is held in a data FIFO(8 words depth), the value in data FIFO is pushed to DAC analog portion for conversion on a selected edge of an input SYNC signal. In the Automatic mode, the DAC is used to generate different types of waveforms, data FIFO is disconnected from DAC analog portion in this mode, DAC output is determined by buffered STEP, MIN and MAX value registers. The SYNC signal is used to updated STEP, MIN and MAX registers from their buffers and reset the output wavefrom as well. A fast refresh signals(generated within DAC) is used to update DAC output based on STEP, MIN and MAX. The details of those operation modes will be provided in the following sections.

Features

How this peripheral works

How this driver is designed to make this peripheral works.

This driver is designed with one DAC_Init() function and multiple register access level APIs. DAC_Init() can realize all the possible DAC configurations. Users need to invoke DAC_Init() firstly and then use other functions such as DAC_WriteDataFIFO() in the runtime.

How to use this driver

For initialization:

For runtime DAC update:

Typical Use Case

  1. Normal operation mode + Clock selected as SYNC signal. In this type of use case, the DAC is used to generate voltage output, and when the data is written to the DAC's DATA FIFO, the data can be almost immediately presented to the DAC output. The template of this type of use case is shown below.
    dac_config_t sDacConfig;
    DAC_GetDefaultConfig(&sDacConfig);
    sDacConfig.eOperationMode = kDAC_NormalMode;
    sDacConfig.uOperationConfig.sNormalModeConfig.u16DataFIFO = 4095; (Each DAC LSB represent 0.806mV)
    sDacConfig.bEnableAnalogPortion = true;
    DAC_Init(DACA, &sDacConfig);
    In this template, the 3.3V voltage will be generated on the DAC output pin. During runtime, invoke DAC_WriteDataFIFO() to change DAC output, such as DAC_WriteDataFIFO(DAC_BASE, 2048), where DAC outputs 1.65V.
  2. Automatic operation mode + External SYNC_IN signal selected as SYNC signal. In this type of use case, the DAC is used to generate a waveform, and the SYNC_IN signal controls when the values of the buffered registers are updated. The update occurs on the active edge of the SYNC_IN signal if DAC_SetLDOK() function is invoked. The active edge of SYNC_IN will also cause the automatic waveform to be reset to its start point as defined by the new minimum value and maximum value. The SYNC_IN signal can come from a timer, comparator, pins, or other sources through the crossbar. The template of this type of use case is shown below.
    1. Initialize the DAC module with automatic operation mode and SYNC_IN signal.
      dac_config_t sDacConfig;
      DAC_GetDefaultConfig(&sDacConfig);
      sDacConfig.eSyncInputEdge = kDAC_RisingEdge;
      sDacConfig.uOperationConfig.sAutomaticModeConfig.u16StepSize = 50;
      sDacConfig.uOperationConfig.sAutomaticModeConfig.u16CompareValue = 200U;
      sDacConfig.bEnableAnalogPortion = true;
      DAC_Init(DACA, &sDacConfig);
      After this initialization, a ramping down sawtooth waveform will be generated on the DAC output pin. Supposes SYNC_IN signal is 10kHz, because REFERSH signal is configured as 500kHz(bus clock is 100MHz), the sawtooth waveform will be similar as the one shown in kDAC_OneShotSawtoothWaveform1.
    2. Update waveform(maximum value/minimum value/step size)during runtime.
      DAC_WriteMinValue(DACA, 800);
      DAC_WriteMaxValue(DACA, 2000);
      DAC_SetLDOK(DACA);
      When the active edge of SYNC_IN signal occurs, a new sawtooth waveform will be generated on the DAC output pin.