CC26xx Driver Library

Functions

void AUXDACSetVref (uint8_t refSource)
 Sets the voltage reference source. More...
 
void AUXDACEnablePreCharge (void)
 Enables DAC precharge. More...
 
void AUXDACDisablePreCharge (void)
 Disables DAC precharge. More...
 
uint32_t AUXDACCalcMax (void)
 Calculates the upper limit voltage the DAC can output. More...
 
uint32_t AUXDACCalcMin (void)
 Calculates the lower limit voltage the DAC can output. More...
 
uint32_t AUXDACCalcCode (uint32_t uVoltOut, uint32_t uVoltOutMin, uint32_t uVoltOutMax)
 Calculates the appropriate DAC code for a specific voltage value. More...
 
void AUXDACSetSampleClock (uint8_t dacClkDiv)
 Configures and sets the DAC sample clock. More...
 
void AUXDACSetCode (uint8_t dacCode)
 Updates the current DAC code. More...
 
void AUXDACEnable (uint8_t dacPinId)
 Enables the DAC. More...
 
void AUXDACDisable (void)
 Disables the DAC. More...
 

Detailed Description

Function Documentation

uint32_t AUXDACCalcCode ( uint32_t  uVoltOut,
uint32_t  uVoltOutMin,
uint32_t  uVoltOutMax 
)

Calculates the appropriate DAC code for a specific voltage value.

Once a voltage reference source has been selected with AUXDACSetVref and the DAC's output voltage range has been defined with AUXDACCalcMin and AUXDACCalcMax, a DAC code can be derived.

Parameters
uVoltOutThe desired output voltage in millivolts [mV].
uVoltOutMinThe minimum output voltage in millivolts [mV] which can be output by the DAC in the current configuration. It should be the value returned by AUXDACCalcMin.
uVoltOutMaxThe maximum output voltage in millivolts [mV] which can be output by the DAC in the current configuration. It should be the value returned by AUXDACCalcMax.
Returns
The dac code corresponding to the desired output value.
190 {
191  uint32_t dacCode = 0;
192 
193  if(uVoltOut != 0)
194  {
195  // Rounding (by adding 0.5 before truncating)
196  dacCode = (((254 * (uVoltOut - uVoltOutMin) * 2) / (uVoltOutMax - uVoltOutMin) + 1) / 2) + 1;
197  }
198  return (uint32_t)dacCode;
199 }
uint32_t AUXDACCalcMax ( void  )

Calculates the upper limit voltage the DAC can output.

This function uses calibration coefficients stored in the factory configuration area (FCFG1) to determine the DAC's output voltage that corresponds to DAC code 255. This voltage depends on the selected voltage reference source.

Note
This function must only be called after AUXDACSetVref has been called.
Returns
The maximum voltage in mV that the DAC can output given a specific reference voltage.
87 {
88  uint32_t prechargeStatus;
89  uint32_t refSource;
90  uint32_t dacMax;
91 
92  // Depending on the selected DAC voltage reference, obtain calibration value C2 in millivolts.
94 
95  switch (refSource)
96  {
97  // Nothing connected. Input is floating.
98  case AUXDAC_VREF_SEL_NC:
99 
100  dacMax = 0;
101  break;
102 
103  // Core Voltage Decoupling pin as the DAC's voltage reference source.
105 
109  break;
110 
111  // ADC reference voltage as the DAC's voltage reference source.
113 
115  break;
116 
117  // Main supply voltage VDDS as the DAC's voltage reference source.
119 
120  // Note: The calibration value is measured at a VDDS of 3.0V. If VDDS is selected as reference,
121  // measure VDDS and scale the calibration value.
123  break;
124 
125  // Nothing connected. Input is floating.
126  default:
127 
128  dacMax = 0;
129  }
130 
131  return dacMax;
132 }
#define AUXDAC_VREF_SEL_VDDS
Definition: aux_dac.h:101
#define AUXDAC_VREF_SEL_NC
Definition: aux_dac.h:104
#define AUXDAC_VREF_SEL_DCOUPL
Definition: aux_dac.h:103
#define AUXDAC_VREF_SEL_ADCREF
Definition: aux_dac.h:102
uint32_t AUXDACCalcMin ( void  )

Calculates the lower limit voltage the DAC can output.

This function uses calibration coefficients stored in the factory configuration area (FCFG1) to determine the DAC's output voltage that corresponds to DAC code 1. This voltage depends on the selected voltage reference source.

DAC Code 0 corresponds to 0 V. Therefore, the DAC can only output 0 V and values between the lower limit defined by this function and the upper limit defined by AUXDACCalcMax.

Note
This function must only be called after AUXDACSetVref has been called.
Returns
The minimum voltage (other than 0 V) in mV that the DAC can output given a specific reference voltage.
141 {
142  uint32_t refSource;
143  uint32_t prechargeStatus;
144  uint32_t dacMin;
145 
146  // Depending on the selected DAC voltage reference, obtain calibration value C1 in millivolts.
148 
149  switch (refSource)
150  {
151  // Nothing connected. Input is floating.
152  case AUXDAC_VREF_SEL_NC:
153  dacMin = 0;
154  break;
155 
156  // Core Voltage Decoupling pin as the DAC's voltage reference source.
158 
162  break;
163 
164  // ADC reference voltage as the DAC's voltage reference source.
167  break;
168 
169  // Main supply voltage VDDS as the DAC's voltage reference source.
172  break;
173 
174  // Nothing connected. Input is floating.
175  default:
176 
177  dacMin = 0;
178  }
179 
180  return dacMin;
181 }
#define AUXDAC_VREF_SEL_VDDS
Definition: aux_dac.h:101
#define AUXDAC_VREF_SEL_NC
Definition: aux_dac.h:104
#define AUXDAC_VREF_SEL_DCOUPL
Definition: aux_dac.h:103
#define AUXDAC_VREF_SEL_ADCREF
Definition: aux_dac.h:102
void AUXDACDisable ( void  )

Disables the DAC.

This function disables the DAC sample clock, the DAC buffer, the DAC. It also disconnects COMPA_IN internally.

Note
This function must be called only after AUXDACEnable has been called.
260 {
261  // Disable the DAC sample clock
262  HWREGB(AUX_ANAIF_BASE + AUX_ANAIF_O_DACSMPLCTL) = 0x0;
263 
264  // Disable DAC, the DAC's buffer, and disconnect internally.
268 
269  // Disconnect COMPA_IN from DIOs
270  HWREGB(AUX_ADI4_BASE + ADI_4_AUX_O_MUX1) = 0x0;
271 }
void AUXDACDisablePreCharge ( void  )

Disables DAC precharge.

If AUXDAC_VREF_SEL_DCOUPL has been selected as a voltage reference source, the DAC's output voltage range can be further controlled by enabling or disabling precharge.

When precharge is disabled the DAC's output voltage will range from 0 V to 1.28 V.

Note
This function must only be called if AUXDAC_VREF_SEL_DCOUPL has been selected as a voltage reference source and while the DAC is disabled, before calling AUXDACEnable().
void AUXDACEnable ( uint8_t  dacPinId)

Enables the DAC.

This function enables the DAC sample clock and the DAC buffer. It selects COMPA_IN as output, and it routes the DAC's output to the given I/O pin.

Parameters
dacPinIdAnalog capable I/O pin:
236 {
237  // Set the operational mode to active
239 
240  // Disable the low power bias control
241  HWREGB(AUX_ANAIF_BASE + AUX_ANAIF_O_LPMBIASCTL) = 0x0;
242 
243  // Enable the DAC sample clock
245 
246  // Enable DAC and buffer and set COMPA_IN
248 
249  // Select COMPA output (0 will disconnect from DIOs)
250  HWREGB(AUX_ADI4_BASE + ADI_4_AUX_O_MUX1) = dacPinId;
251 }
void AUXDACEnablePreCharge ( void  )

Enables DAC precharge.

If AUXDAC_VREF_SEL_DCOUPL has been selected as a voltage reference source, the DAC's output voltage range can be further controlled by enabling or disabling precharge.

When precharge is enabled the DAC's output voltage will range from 1.28 V to 2.56 V.

Note
This function must only be called if AUXDAC_VREF_SEL_DCOUPL has been selected as a voltage reference source and while the DAC is disabled, before calling AUXDACEnable().
void AUXDACSetCode ( uint8_t  dacCode)

Updates the current DAC code.

This function is meant to be used after AUXDACEnable has been called. It allows to update the DAC code by rapidly disabling the DAC, setting the new DAC code, and then rapidly re-enabling the DAC.

Parameters
dacCodeThe new DAC code
224 {
225  // Update the DAC's output value.
226  HWREGB(AUX_ANAIF_BASE + AUX_ANAIF_O_DACVALUE) = dacCode;
227 }
void AUXDACSetSampleClock ( uint8_t  dacClkDiv)

Configures and sets the DAC sample clock.

This function determines the sample clock base frequency considering that the operational rate for the DAC sample clock state machine is the AUX Bus Rate.

AUX Bus Rate divided by (dacClkDiv + 1) determines the sample clock base frequency.

Note
This function must be called before AUXDACEnable.
Parameters
dacClkDivThe clock division factor
208 {
209 
210  // Set the peripheral operational rate to the AUX bus rate of 24 MHz.
212 
213  // Set sample clock frequency considering a clock base frequency of 24 MHz and the given clock divider.
214  HWREGB(AUX_ANAIF_BASE + AUX_ANAIF_O_DACSMPLCFG0) = dacClkDiv;
215 }
void AUXDACSetVref ( uint8_t  refSource)

Sets the voltage reference source.

The DAC's output range depends on the selection of a voltage reference source. This function must be called before enabling the DAC using AUXDACEnable() or before setting a DAC code using AUXDACCalcCode().

Parameters
refSourceDAC voltage reference source:
48 {
49  HWREGB(AUX_ADI4_BASE + ADI_4_AUX_O_MUX2) = refSource;
50 
51  if(refSource == AUXDAC_VREF_SEL_ADCREF)
52  {
53  // Enable the ADC reference module.
55  }
56 }
#define AUXDAC_VREF_SEL_ADCREF
Definition: aux_dac.h:102

Macro Definition Documentation

#define AUXDAC_COMPA_IN_AUXIO0   AUXDAC_COMPA_IN_AUXIO19
#define AUXDAC_COMPA_IN_AUXIO1   AUXDAC_COMPA_IN_AUXIO20
#define AUXDAC_COMPA_IN_AUXIO19   0x80
#define AUXDAC_COMPA_IN_AUXIO2   AUXDAC_COMPA_IN_AUXIO21
#define AUXDAC_COMPA_IN_AUXIO20   0x40
#define AUXDAC_COMPA_IN_AUXIO21   0x20
#define AUXDAC_COMPA_IN_AUXIO22   0x10
#define AUXDAC_COMPA_IN_AUXIO23   0x08
#define AUXDAC_COMPA_IN_AUXIO24   0x04
#define AUXDAC_COMPA_IN_AUXIO25   0x02
#define AUXDAC_COMPA_IN_AUXIO26   0x01
#define AUXDAC_COMPA_IN_AUXIO3   AUXDAC_COMPA_IN_AUXIO22
#define AUXDAC_COMPA_IN_AUXIO4   AUXDAC_COMPA_IN_AUXIO23
#define AUXDAC_COMPA_IN_AUXIO5   AUXDAC_COMPA_IN_AUXIO24
#define AUXDAC_COMPA_IN_AUXIO6   AUXDAC_COMPA_IN_AUXIO25
#define AUXDAC_COMPA_IN_AUXIO7   AUXDAC_COMPA_IN_AUXIO26
#define AUXDAC_COMPA_IN_NC   0x00
#define AUXDAC_VREF_SEL_ADCREF   ADI_4_AUX_MUX2_DAC_VREF_SEL_ADCREF
#define AUXDAC_VREF_SEL_DCOUPL   ADI_4_AUX_MUX2_DAC_VREF_SEL_DCOUPL

Referenced by AUXDACCalcMax(), and AUXDACCalcMin().

#define AUXDAC_VREF_SEL_NC   ADI_4_AUX_MUX2_DAC_VREF_SEL_NC

Referenced by AUXDACCalcMax(), and AUXDACCalcMin().

#define AUXDAC_VREF_SEL_VDDS   ADI_4_AUX_MUX2_DAC_VREF_SEL_VDDS

Referenced by AUXDACCalcMax(), and AUXDACCalcMin().