# DAC Module

The buffered digital to analog converter (DAC) API provides a set of functions for programming the digital circuits of the DAC. Functions are provided to set the reference voltage, the synchronization mode, the internal 12-bit DAC value, and set the state of the DAC output.

group `dac_api`

  Defines

  `DAC_REG_BYTE_MASK` (0xFFU)

    Register Byte Mask.

  `DAC_LOCK_KEY` (0xA000U)

    DAC Lock Key.

  `DAC_LOCK_CONTROL` (0x1U)

    Lock the control register.

  `DAC_LOCK_SHADOW` (0x2U)

    Lock the shadow value register.

  `DAC_LOCK_OUTPUT` (0x4U)

    Lock the output enable register.

  Enums

  enum `DAC_ReferenceVoltage`

    Values that can be passed to DAC_setReferenceVoltage() as the source parameter.

    Values:

    enumerator `DAC_REF_VDAC` = 0

      VDAC reference voltage.

    enumerator `DAC_REF_ADC_VREFHI` = 1

      ADC VREFHI reference voltage.

  enum `DAC_GainMode`

    Values that can be passed to DAC_setGainMode() as the mode parameter.

    Values:

    enumerator `DAC_GAIN_ONE` = 0

      Gain set to 1.

    enumerator `DAC_GAIN_TWO` = 2

      Gain set to 2.

  enum `DAC_LoadMode`

    Values that can be passed to DAC_setLoadMode() as the mode parameter.

    Values:

    enumerator `DAC_LOAD_SYSCLK` = 0

      Load on next SYSCLK.

    enumerator `DAC_LOAD_PWMSYNC` = 4

      Load on next PWMSYNC specified by SYNCSEL.

  Functions

  uint16_t `DAC_getRevision`(uint32_t base)

    Get the DAC Revision value

    This function gets the DAC revision value.

    Parameters

      - `base`: is the DAC module base address

    Return

      Returns the DAC revision value.

  void `DAC_setReferenceVoltage`(uint32_t base, DAC_ReferenceVoltage source)

    Sets the DAC Reference Voltage

    This function sets the DAC reference voltage.

    Parameters

      - `base`: is the DAC module base address

      - `source`: is the selected reference voltage

    The source parameter can have the following value:

    - DAC_REF_VDAC - The VDAC reference voltage

    - DAC_REF_ADC_VREFHI - The ADC VREFHI reference voltage

    Return

      None.

  void `DAC_setGainMode`(uint32_t base, DAC_GainMode mode)

    Sets the DAC Gain Mode

    This function sets the DAC gain mode for the buffered output.

    Parameters

      - `base`: is the DAC module base address

      - `mode`: is the selected gain mode

    The mode parameter can have one of two values:

    - DAC_GAIN_ONE - Gain is set to 1

    - DAC_GAIN_TWO - Gain is set to 2

    Note

      This value is only used when DAC_REF_ADC_VREFHI is set using DAC_setReferenceVoltage() and internal ADC reference mode is selected.

    Return

      None.

  void `DAC_setLoadMode`(uint32_t base, DAC_LoadMode mode)

    Sets the DAC Load Mode

    This function sets the DAC load mode.

    Parameters

      - `base`: is the DAC module base address

      - `mode`: is the selected load mode

    The mode parameter can have one of two values:

    - DAC_LOAD_SYSCLK - Load on next SYSCLK

    - DAC_LOAD_PWMSYNC - Load on next PWMSYNC specified by SYNCSEL

    Return

      None.

  void `DAC_setPWMSyncSignal`(uint32_t base, uint16_t pwmSignal)

    Sets the DAC PWMSYNC Signal

    This function sets the DAC PWMSYNC signal.

    Parameters

      - `base`: is the DAC module base address

      - `signal`: is the selected PWM signal

    The signal parameter must be set to a number that represents the PWM signal that will be set. For instance, passing 2 into signal will select PWM sync signal 2.

    Return

      None.

  uint16_t `DAC_getActiveValue`(uint32_t base)

    Get the DAC Active Output Value

    This function gets the DAC active output value.

    Parameters

      - `base`: is the DAC module base address

    Return

      Returns the DAC active output value.

  void `DAC_setShadowValue`(uint32_t base, uint16_t value)

    Set the DAC Shadow Output Value

    This function sets the DAC shadow output value.

    Parameters

      - `base`: is the DAC module base address

      - `value`: is the 12-bit code to be loaded into the active value register

    Return

      None.

  uint16_t `DAC_getShadowValue`(uint32_t base)

    Get the DAC Shadow Output Value

    This function gets the DAC shadow output value.

    Parameters

      - `base`: is the DAC module base address

    Return

      Returns the DAC shadow output value.

  void `DAC_enableOutput`(uint32_t base)

    Enable the DAC Output

    This function enables the DAC output.

    Parameters

      - `base`: is the DAC module base address

    Note

      A delay is required after enabling the DAC. Further details regarding the exact delay time length can be found in the device datasheet.

    Return

      None.

  void `DAC_disableOutput`(uint32_t base)

    Disable the DAC Output

    This function disables the DAC output.

    Parameters

      - `base`: is the DAC module base address

    Return

      None.

  void `DAC_setOffsetTrim`(uint32_t base, int16_t offset)

    Set DAC Offset Trim

    This function sets the DAC offset trim. The

    offset value should be a signed number in the range of -128 to 127.
    Parameters

      - `base`: is the DAC module base address

      - `offset`: is the specified value for the offset trim

    Note

      The offset should not be modified unless specifically indicated by TI Errata or other documentation. Modifying the offset value could cause this module to operate outside of the datasheet specifications.

    Return

      None.

  int16_t `DAC_getOffsetTrim`(uint32_t base)

    Get DAC Offset Trim

    This function gets the DAC offset trim value.

    Parameters

      - `base`: is the DAC module base address

    Return

      None.

  void `DAC_lockRegister`(uint32_t base, uint16_t reg)

    Lock write-access to DAC Register

    This function locks the write-access to the specified DAC register. Only a system reset can unlock the register once locked.

    Parameters

      - `base`: is the DAC module base address

      - `reg`: is the selected DAC registers

    The reg parameter can be an ORed combination of any of the following values:

    - DAC_LOCK_CONTROL - Lock the DAC control register

    - DAC_LOCK_SHADOW - Lock the DAC shadow value register

    - DAC_LOCK_OUTPUT - Lock the DAC output enable/disable register

    Return

      None.

  bool `DAC_isRegisterLocked`(uint32_t base, uint16_t reg)

    Check if DAC Register is locked

    This function checks if write-access has been locked on the specified DAC register.

    Parameters

      - `base`: is the DAC module base address

      - `reg`: is the selected DAC register locks to check

    The reg parameter can be an ORed combination of any of the following values:

    - DAC_LOCK_CONTROL - Lock the DAC control register

    - DAC_LOCK_SHADOW - Lock the DAC shadow value register

    - DAC_LOCK_OUTPUT - Lock the DAC output enable/disable register

    Return

      Returns true if any of the registers specified are locked, and false if all specified registers aren’t locked.

  void `DAC_tuneOffsetTrim`(uint32_t base, float32_t referenceVoltage)

    Tune DAC Offset Trim

    This function adjusts/tunes the DAC offset trim. The

    referenceVoltage value should be a floating point number in the range specified in the device data manual.
    Parameters

      - `base`: is the DAC module base address

      - `referenceVoltage`: is the reference voltage the DAC module is operating at.

    Note

      Use this function to adjust the DAC offset trim if operating at a reference voltage other than 2.5v. Since this function modifies the DAC offset trim register, it should only be called once after Device_cal. If it is called multiple times after Device_cal, the offset value scaled would be the wrong value.

    Return

      None.

The code for this module is contained in driverlib/dac.c, with driverlib/dac.h containing the API declarations for use by applications.