MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
DAC32: Digital-to-Analog Converter

Overview

The MCUXpresso SDK provides a peripheral driver for the Digital-to-Analog Converter (DAC32) module of MCUXpresso SDK devices.

The DAC32 driver includes a basic DAC32 module (converter) and DAC32 buffer.

The basic DAC32 module supports operations unique to the DAC converter in each DAC32 instance. The APIs in this part are used in the initialization phase, which is necessary for enabling the DAC32 module in the application. The APIs enable/disable the clock, enable/disable the module, and configure the converter. Call the initial APIs to prepare the DAC32 module for the application.

The DAC32 buffer operates the DAC32 hardware buffer. The DAC32 module supports a hardware buffer to keep a group of DAC values to be converted. This feature supports updating the DAC output value automatically by triggering the buffer read pointer to move in the buffer. Use the APIs to configure the hardware buffer's trigger mode, watermark, work mode, and use size. Additionally, the APIs operate the DMA, interrupts, flags, the pointer (index of buffer), item values, and so on.

The DAC32 buffer plays a major part when using the DAC module, as the most functional features are designed for the DAC32 hardware buffer.

Function groups

Initialization and deinitialization

This function group implements APIs for the basic DAC module (converter).

Buffer

This function group implements APIs for the DAC buffer.

Typical use case

Working as a basic DAC without the hardware buffer feature.

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

Working with the hardware buffer.

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

Data Structures

struct  dac32_config_t
 DAC32 module configuration. More...
 
struct  dac32_buffer_config_t
 DAC32 buffer configuration. More...
 

Macros

#define FSL_DAC32_DRIVER_VERSION   (MAKE_VERSION(2, 0, 2))
 DAC32 driver version. More...
 

Enumerations

enum  _dac32_buffer_status_flags {
  kDAC32_BufferWatermarkFlag = DAC_STATCTRL_DACBFWMF_MASK,
  kDAC32_BufferReadPointerTopPositionFlag,
  kDAC32_BufferReadPointerBottomPositionFlag = DAC_STATCTRL_DACBFRPBF_MASK
}
 DAC32 buffer flags. More...
 
enum  _dac32_buffer_interrupt_enable {
  kDAC32_BufferWatermarkInterruptEnable = DAC_STATCTRL_DACBWIEN_MASK,
  kDAC32_BufferReadPointerTopInterruptEnable = DAC_STATCTRL_DACBTIEN_MASK,
  kDAC32_BufferReadPointerBottomInterruptEnable = DAC_STATCTRL_DACBBIEN_MASK
}
 DAC32 buffer interrupts. More...
 
enum  dac32_reference_voltage_source_t {
  kDAC32_ReferenceVoltageSourceVref1 = 0U,
  kDAC32_ReferenceVoltageSourceVref2 = 1U
}
 DAC32 reference voltage source. More...
 
enum  dac32_buffer_trigger_mode_t {
  kDAC32_BufferTriggerByHardwareMode = 0U,
  kDAC32_BufferTriggerBySoftwareMode = 1U
}
 DAC32 buffer trigger mode. More...
 
enum  dac32_buffer_watermark_t {
  kDAC32_BufferWatermark1Word = 0U,
  kDAC32_BufferWatermark2Word = 1U,
  kDAC32_BufferWatermark3Word = 2U,
  kDAC32_BufferWatermark4Word = 3U
}
 DAC32 buffer watermark. More...
 
enum  dac32_buffer_work_mode_t {
  kDAC32_BufferWorkAsNormalMode = 0U,
  kDAC32_BufferWorkAsSwingMode = 1U,
  kDAC32_BufferWorkAsOneTimeScanMode = 2U,
  kDAC32_BufferWorkAsFIFOMode = 3U
}
 DAC32 buffer work mode. More...
 

Initialization and deinitiailzation

void DAC32_Init (DAC_Type *base, const dac32_config_t *config)
 Initializes the DAC32 module. More...
 
void DAC32_Deinit (DAC_Type *base)
 De-initializes the DAC32 module. More...
 
void DAC32_GetDefaultConfig (dac32_config_t *config)
 Initializes the DAC32 user configuration structure. More...
 
static void DAC32_Enable (DAC_Type *base, bool enable)
 Enables the DAC32 module. More...
 

Buffer

static void DAC32_EnableBuffer (DAC_Type *base, bool enable)
 Enables the DAC32 buffer. More...
 
void DAC32_SetBufferConfig (DAC_Type *base, const dac32_buffer_config_t *config)
 Configures the DAC32 buffer. More...
 
void DAC32_GetDefaultBufferConfig (dac32_buffer_config_t *config)
 Initializes the DAC32 buffer configuration structure. More...
 
static void DAC32_EnableBufferDMA (DAC_Type *base, bool enable)
 Enables the DMA for DAC32 buffer. More...
 
void DAC32_SetBufferValue (DAC_Type *base, uint32_t index, uint32_t value)
 Sets the value for items in the buffer. More...
 
static void DAC32_DoSoftwareTriggerBuffer (DAC_Type *base)
 Triggers the buffer by software and updates the read pointer of the DAC32 buffer. More...
 
static uint32_t DAC32_GetBufferReadPointer (DAC_Type *base)
 Gets the current read pointer of the DAC32 buffer. More...
 
static void DAC32_SetBufferReadPointer (DAC_Type *base, uint32_t index)
 Sets the current read pointer of the DAC32 buffer. More...
 
static void DAC32_EnableBufferInterrupts (DAC_Type *base, uint32_t mask)
 Enables interrupts for the DAC32 buffer. More...
 
static void DAC32_DisableBufferInterrupts (DAC_Type *base, uint32_t mask)
 Disables interrupts for the DAC32 buffer. More...
 
static uint32_t DAC32_GetBufferStatusFlags (DAC_Type *base)
 Gets the flags of events for the DAC32 buffer. More...
 
static void DAC32_ClearBufferStatusFlags (DAC_Type *base, uint32_t mask)
 Clears the flags of events for the DAC32 buffer. More...
 
static void DAC32_EnableBufferOutput (DAC_Type *base, bool enable)
 Enable the buffer output. More...
 
static void DAC32_EnableTestOutput (DAC_Type *base, bool enable)
 Enable the test output. More...
 

Data Structure Documentation

struct dac32_config_t

Data Fields

dac32_reference_voltage_source_t referenceVoltageSource
 Select the DAC32 reference voltage source. More...
 
bool enableLowPowerMode
 Enable the low power mode. More...
 

Field Documentation

dac32_reference_voltage_source_t dac32_config_t::referenceVoltageSource
bool dac32_config_t::enableLowPowerMode
struct dac32_buffer_config_t

Data Fields

dac32_buffer_trigger_mode_t triggerMode
 Select the buffer's trigger mode. More...
 
dac32_buffer_watermark_t watermark
 Select the buffer's watermark. More...
 
dac32_buffer_work_mode_t workMode
 Select the buffer's work mode. More...
 
uint32_t upperLimit
 Set the upper limit for buffer index. More...
 

Field Documentation

dac32_buffer_trigger_mode_t dac32_buffer_config_t::triggerMode
dac32_buffer_watermark_t dac32_buffer_config_t::watermark
dac32_buffer_work_mode_t dac32_buffer_config_t::workMode
uint32_t dac32_buffer_config_t::upperLimit

Normally, 0-15 is available for buffer with 16 item.

Macro Definition Documentation

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

Version 2.0.2.

Enumeration Type Documentation

Enumerator
kDAC32_BufferWatermarkFlag 

DAC32 Buffer Watermark Flag.

kDAC32_BufferReadPointerTopPositionFlag 

DAC32 Buffer Read Pointer Top Position Flag.

kDAC32_BufferReadPointerBottomPositionFlag 

DAC32 Buffer Read Pointer Bottom Position Flag.

Enumerator
kDAC32_BufferWatermarkInterruptEnable 

DAC32 Buffer Watermark Interrupt Enable.

kDAC32_BufferReadPointerTopInterruptEnable 

DAC32 Buffer Read Pointer Top Flag Interrupt Enable.

kDAC32_BufferReadPointerBottomInterruptEnable 

DAC32 Buffer Read Pointer Bottom Flag Interrupt Enable.

Enumerator
kDAC32_ReferenceVoltageSourceVref1 

The DAC32 selects DACREF_1 as the reference voltage.

kDAC32_ReferenceVoltageSourceVref2 

The DAC32 selects DACREF_2 as the reference voltage.

Enumerator
kDAC32_BufferTriggerByHardwareMode 

The DAC32 hardware trigger is selected.

kDAC32_BufferTriggerBySoftwareMode 

The DAC32 software trigger is selected.

Enumerator
kDAC32_BufferWatermark1Word 

1 word away from the upper limit.

kDAC32_BufferWatermark2Word 

2 words away from the upper limit.

kDAC32_BufferWatermark3Word 

3 words away from the upper limit.

kDAC32_BufferWatermark4Word 

4 words away from the upper limit.

Enumerator
kDAC32_BufferWorkAsNormalMode 

Normal mode.

kDAC32_BufferWorkAsSwingMode 

Swing mode.

kDAC32_BufferWorkAsOneTimeScanMode 

One-Time Scan mode.

kDAC32_BufferWorkAsFIFOMode 

FIFO mode.

Function Documentation

void DAC32_Init ( DAC_Type *  base,
const dac32_config_t config 
)

This function initializes the DAC32 module, including:

  • Enabling the clock for DAC32 module.
  • Configuring the DAC32 converter with a user configuration.
  • Enabling the DAC32 module.
Parameters
baseDAC32 peripheral base address.
configPointer to the configuration structure. See "dac32_config_t".
void DAC32_Deinit ( DAC_Type *  base)

This function de-initializes the DAC32 module, including:

  • Disabling the DAC32 module.
  • Disabling the clock for the DAC32 module.
Parameters
baseDAC32 peripheral base address.
void DAC32_GetDefaultConfig ( dac32_config_t config)

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

* config->referenceVoltageSource = kDAC32_ReferenceVoltageSourceVref2;
* config->enableLowPowerMode = false;
*
Parameters
configPointer to the configuration structure. See "dac32_config_t".
static void DAC32_Enable ( DAC_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseDAC32 peripheral base address.
enableEnables the feature or not.
static void DAC32_EnableBuffer ( DAC_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseDAC32 peripheral base address.
enableEnables the feature or not.
void DAC32_SetBufferConfig ( DAC_Type *  base,
const dac32_buffer_config_t config 
)
Parameters
baseDAC32 peripheral base address.
configPointer to the configuration structure. See "dac32_buffer_config_t".
void DAC32_GetDefaultBufferConfig ( dac32_buffer_config_t config)

This function initializes the DAC32 buffer configuration structure to a default value. The default values are:

* config->triggerMode = kDAC32_BufferTriggerBySoftwareMode;
* config->watermark = kDAC32_BufferWatermark1Word;
* config->workMode = kDAC32_BufferWorkAsNormalMode;
* config->upperLimit = DAC_DAT_COUNT * 2U - 1U;
*
Parameters
configPointer to the configuration structure. See "dac32_buffer_config_t".
static void DAC32_EnableBufferDMA ( DAC_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseDAC32 peripheral base address.
enableEnables the feature or not.
void DAC32_SetBufferValue ( DAC_Type *  base,
uint32_t  index,
uint32_t  value 
)
Parameters
baseDAC32 peripheral base address.
indexSetting index for items in the buffer. The available index should not exceed the size of the DAC32 buffer.
valueSetting value for items in the buffer. 12-bits are available.
static void DAC32_DoSoftwareTriggerBuffer ( DAC_Type *  base)
inlinestatic

This function triggers the function by software. The read pointer of the DAC32 buffer is updated with one step after this function is called. Changing the read pointer depends on the buffer's work mode.

Parameters
baseDAC32 peripheral base address.
static uint32_t DAC32_GetBufferReadPointer ( DAC_Type *  base)
inlinestatic

This function gets the current read pointer of the DAC32 buffer. The current output value depends on the item indexed by the read pointer. It is updated by software trigger or hardware trigger.

Parameters
baseDAC32 peripheral base address.
Returns
Current read pointer of DAC32 buffer.
static void DAC32_SetBufferReadPointer ( DAC_Type *  base,
uint32_t  index 
)
inlinestatic

This function sets the current read pointer of the DAC32 buffer. The current output value depends on the item indexed by the read pointer. It is updated by software trigger or hardware trigger. After the read pointer changes, the DAC32 output value also changes.

Parameters
baseDAC32 peripheral base address.
indexSetting index value for the pointer.
static void DAC32_EnableBufferInterrupts ( DAC_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseDAC32 peripheral base address.
maskMask value for interrupts. See "_dac32_buffer_interrupt_enable".
static void DAC32_DisableBufferInterrupts ( DAC_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseDAC32 peripheral base address.
maskMask value for interrupts. See "_dac32_buffer_interrupt_enable".
static uint32_t DAC32_GetBufferStatusFlags ( DAC_Type *  base)
inlinestatic
Parameters
baseDAC32 peripheral base address.
Returns
Mask value for the asserted flags. See "_dac32_buffer_status_flags".
static void DAC32_ClearBufferStatusFlags ( DAC_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseDAC32 peripheral base address.
maskMask value for flags. See "_dac32_buffer_status_flags_t".
static void DAC32_EnableBufferOutput ( DAC_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseDAC32 peripheral base address.
enableEnable the buffer output or not.
static void DAC32_EnableTestOutput ( DAC_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseDAC32 peripheral base address.
enableEnable the test output or not.