Reference
Last revision 2025/12/27
Arduino API guide for DAC output: initialize, set ranges, and generate waveforms.
API Description
/**
* @fn begin
* @brief Initialize the module
*/
uint8_t begin(void);
/**
* @fn setDACOutRange
* @brief Set DAC output range
* @param range DAC output range, 5V or 10V
* @return NONE
*/
void setDACOutRange(eOutPutRange range);
/**
* @fn setDACOutVoltage
* @brief Set output DAC voltage of different channels
* @param data the DAC value corresponding to the voltage to be output
* @param channel Output channel setting, 0: channel 0; 1: channel 1; 2: all the channels
* @return NONE
*/
void setDACOutVoltage(uint16_t data,uint8_t channel);
/**
* @brief Save the set voltage inside the chip
*/
void store(void);
/**
* @brief Call the function to output sine wave
* @param amp Set sine wave amplitude Vp
* @param freq Set sine wave frequency f
* @param offset Set sine wave DC offset Voffset
* @param channel Output channel: 0: channel 0; 1: channel 1; 2: all the channels
*/
void outputSin(uint16_t amp, uint16_t freq, uint16_t offset,uint8_t channel);
/**
* @brief Call the function to output triangle wave
* @param amp Set triangle wave amplitude Vp
* @param freq Set triangle wave frequency f
* @param offset Set triangle wave DC offset Voffset
* @param dutyCycle Set triangle (sawtooth) wave duty cycle
* @param channel Output channel: 0: channel 0; 1: channel 1; 2: all the channels
*/
void outputTriangle(uint16_t amp, uint16_t freq, uint16_t offset, int8_t dutyCycle, uint8_t channel);
/**
* @brief Call the function to output square wave
* @param amp Set square wave amplitude Vp
* @param freq Set square wave frequency f
* @param offset Set square wave DC offset Voffset
* @param dutyCycle Set square wave duty cycle
* @param channel Output channel: 0: channel 0; 1: channel 1; 2: all the channels
*/
void outputSquare(uint16_t amp, uint16_t freq, uint16_t offset, int8_t dutyCycle, uint8_t channel);
Was this article helpful?
