All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
DAC: 10-bit Digital To Analog Converter Driver

## Overview

The MCUXpresso SDK provides a peripheral driver for the 10-bit digital to analog converter (DAC) module of MCUXpresso SDK devices.

# Typical use case

## Polling Configuration

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/dac

## Interrupt Configuration

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/dac

## Files

file | fsl_dac.h

## Data Structures

struct | dac_config_t
| The configuration of DAC. More...

## Enumerations

enum | dac_settling_time_t { kDAC_SettlingTimeIs1us = 0U, kDAC_SettlingTimeIs25us = 1U }
| The DAC settling time. More...

## Functions

void | DAC_Init (DAC_Type *base, const dac_config_t *config)
| Initialize the DAC module. More...
void | DAC_Deinit (DAC_Type *base)
| De-Initialize the DAC module. More...
void | DAC_GetDefaultConfig (dac_config_t *config)
| Initializes the DAC user configuration structure. More...
void | DAC_EnableDoubleBuffering (DAC_Type *base, bool enable)
| Enable/Diable double-buffering feature. More...
void | DAC_SetBufferValue (DAC_Type *base, uint32_t value)
| Write DAC output value into CR register or pre-buffer. More...
void | DAC_SetCounterValue (DAC_Type *base, uint32_t value)
| Write DAC counter value into CNTVAL register. More...
static void | DAC_EnableCounter (DAC_Type *base, bool enable)
| Enable/Disable the counter operation. More...
static bool | DAC_GetDMAInterruptRequestFlag (DAC_Type *base)
| Get the status flag of DMA or interrupt request. More...

## Driver version

#define | LPC_DAC_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
| DAC driver version 2.0.2. More...

## Data Structure Documentation

struct dac_config_t

### Data Fields

dac_settling_time_t | settlingTime
| The settling times are valid for a capacitance load on the DAC_OUT pin not exceeding 100 pF. More...

#### Field Documentation

dac_settling_time_t dac_config_t::settlingTime

A load impedance value greater than that value will cause settling time longer than the specified time. One or more graphs of load impedance vs. settling time will be included in the final data sheet.

## Macro Definition Documentation

#define LPC_DAC_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))

## Enumeration Type Documentation

enum dac_settling_time_t

Enumerator
kDAC_SettlingTimeIs1us | The settling time of the DAC is 1us max, and the maximum current is 700 mA. This allows a maximum update rate of 1 MHz.
kDAC_SettlingTimeIs25us | The settling time of the DAC is 2.5us and the maximum current is 350uA. This allows a maximum update rate of 400 kHz.

## Function Documentation

void DAC_Init | ( | DAC_Type * | base,
|  | const dac_config_t * | config
| ) |  |

Parameters

  base | DAC peripheral base address.
  config | The pointer to configuration structure. Please refer to "dac_config_t" structure.

void DAC_Deinit | ( | DAC_Type * | base | ) |

Parameters

  base | DAC peripheral base address.

void DAC_GetDefaultConfig | ( | dac_config_t * | config | ) |

This function initializes the user configuration structure to a default value. The default values are as follows.

* config->settlingTime = kDAC_SettlingTimeIs1us;
*

Parameters

  config | Pointer to the configuration structure. See "dac_config_t".

void DAC_EnableDoubleBuffering | ( | DAC_Type * | base,
|  | bool | enable
| ) |  |

Notice: Disabling the double-buffering feature will disable counter opreation. If double-buffering feature is disabled, any writes to the CR address will go directly to the CR register. If double-buffering feature is enabled, any write to the CR register will only load the pre-buffer, which shares its register address with the CR register. The CR itself will be loaded from the pre-buffer whenever the counter reaches zero and the DMA request is set.

Parameters

  base | DAC peripheral base address.
  enable | Enable or disable the feature.

void DAC_SetBufferValue | ( | DAC_Type * | base,
|  | uint32_t | value
| ) |  |

The DAC output voltage is VALUE*((VREFP)/1024).

Parameters

  base | DAC peripheral base address.
  value | Setting the value for items in the buffer. 10-bits are available.

void DAC_SetCounterValue | ( | DAC_Type * | base,
|  | uint32_t | value
| ) |  |

       When the counter is enabled bit, the 16-bit counter will begin counting down, at the rate selected by PCLK,
       from the value programmed into the DACCNTVAL register. The counter is decremented Each time the counter

reaches zero, the counter will be reloaded by the value of DACCNTVAL and the DMA request bit INT_DMA_REQ will be set in hardware.

Parameters

  base | DAC peripheral basic address.
  value | Setting the value for items in the counter. 16-bits are available.

static void DAC_EnableCounter | ( | DAC_Type * | base,
|  | bool | enable
| ) |  |

inlinestatic

Parameters

  base | DAC peripheral base address.
  enable | Enable or disable the feature.

static bool DAC_GetDMAInterruptRequestFlag | ( | DAC_Type * | base | ) |

inlinestatic

Parameters

  base | DAC peripheral base address.

Returns
  If return 'true', it means DMA request or interrupt occurs. If return 'false', it means DMA request or interrupt doesn't occur.