SPC  Version 0.9.5
 All Files Functions Groups Pages

The DACnMode controls the operation of the analog output pins O0/O1.

The following modes are available for use:

DAC_MODE_DCOUT0Steady (DC) voltage output
DAC_MODE_SINEWAVE1Sine wave output
DAC_MODE_SQUAREWAVE2Square wave output
DAC_MODE_SAWPOSWAVE3Positive going sawtooth output
DAC_MODE_SAWNEGWAVE4Negative going sawtooth output
DAC_MODE_TRIANGLEWAVE5Triangle wave output
DAC_MODE_PWMVOLTAGE6PWM square wave output
DAC_MODE_RESTART_MASK0x80Restart waveform mask
Analog Output Modes

Mode DAC_MODE_DCOUT uses the DACnVoltage to control the output voltage between 0 and 3.3 volts in steps of 3.222 mV.

The waveforms associated with modes DAC_MODE_SINEWAVE, DAC_MODE_SQUAREWAVE, DAC_MODE_SAWPOSWAVE, DAC_MODE_SAWNEGWAVE, and DAC_MODE_TRIANGLEWAVE are centered around a DC offset of 1.65 volts. The DACnVoltage controls the amplitude from +/- 0 to +/- 1.65 volts.

The waveform associated with mode DAC_MODE_PWMVOLTAGE is a rectangular waveform switching between 0 and 3.3 volts. The DACnVoltage controls the mark to space ratio between 0% and 100%. The average DC value of this waveform thus varies from 0 to 3.3 volts.

DAC0Mode = DAC_MODE_PWMVOLTAGE; // use PWM output
DAC0Frequency = 4000; // 4khz frequency.
DAC0Voltage = 512; // mark/space ratio = 50%

As of firmware version 2.3 the waveform generator has been improved to provide:

  • Seamless change in output frequency if the generator is already running.
  • Start of waveform generation will start from the beginning of the wave table. When the DAC0/DAC1 Mode bytes are changed from 0x00 to a non zero number, the waveform generation will start from the start of the wave table.
  • A frequency value of zero is interpreted as a DC output of 1.65v, the center offset value used for waveform output.
  • Addition of bit 7 of the DAC0/DAC1 Mode bytes to signify force waveform generation from the beginning of the wave table. If the Mode byte is written with bit 7 set, i.e., 0x81 for a sine wave, then the wave table pointer will reset to the start of the table. Once this reset has been performed, the 7 bit will be cleared.
  • Immediate cessation of waveform generation when the DAC0/DAC1 Mode bytes are set to 0x00. The previous firmware version would inadvertently insert a 0 - 4mS dead time when the DAC0/DAC1 Mode bytes were changed to 0x00. The reaction is now a few microseconds instead.