AT11493: Waveform Generator and WAV Audio Player using DAC [APPLICATION NOTE]
Atmel-42458A-Waveform-Generator-and-WAV-Audio-Player-using-DAC_ApplicationNote_042015
and DATABUF registers are write-synchronized. This means that the application software should ensure that
the SYNCBUSY flag is not set before writing to these registers.
The EVCTRL register controls the input and output events to/from the DAC module. The DAC module supports
one event input and one event output. An input event can trigger a DAC conversion action upon reception. The
DAC module can generate an event output when the DAC data buffer is empty. More details on the event
mechanism will be covered in the upcoming section.
The DAC supports three interrupts which are configured through interrupt enable (INTENSET), interrupt
disable (INTENCLR), and interrupt flag (INTFLAG) registers. The interrupts are data buffer empty (EMPTY),
data buffer underrun (UNDERRUN), and synchronization ready (SYNCRDY). The EMPTY interrupt is triggered
when there is no data in the DATABUF register. The UNDERRUN interrupt is triggered when there is no data
in DATABUF register and if an input event occurs. The SYNCRDY interrupt is triggered when the register
synchronization in DAC module is finished.
2.3 DAC Reference
The DAC module in SAM D microcontrollers supports three different reference sources namely:
Internal 1V bandgap reference (INT1V)
AVcc reference (AVCC)
External reference voltage on I/O pin (VREFA)
The INT1V reference source is derived from the voltage reference system in the System Controller (SYSCTRL)
module. In order to use this voltage reference the BGOUTEN bit (Bandgap Output Enable) in VREF register in
SYSCTRL module has to be first set.
The AVcc reference is taken from the analog supply voltage AVCC = VDDANA.
The VREFA is the external voltage reference applied on an I/O pin. In SAM D20 devices, VREFA is alternate
function B on I/O pin PA03.
Note: The external voltage reference option has certain min/max limits. It should be minimum 1.0V and can
be maximum VDDANA – 0.6V. For example if VDDANA = 3.3V, then the maximum external reference
voltage that can be applied is 3.3V – 0.6V = 2.7V.
2.4 DAC Conversion
An input sample conversion in DAC can be either triggered by software or by other peripherals via event
system. Conversion through software is achieved by directly writing to the DATA register in the DAC module.
Writing a digital code to the DATA register will immediately start a conversion.
Event system based conversion is achieved by writing to the DATABUF register. Writing the digital code to the
DATABUF register will keep the data in buffer register and waits for an event to occur to start a conversion. If
the DAC is configured to start a conversion based on an input event and if a valid event happens through the
event channel then the data in the buffer register will be automatically transferred to DATA register and the
conversion is initiated.
Even though a conversion is initiated by an event from Event System, the application software has to write to
the DATABUF register. The advantage of using event based DAC conversion is the deterministic timing
between the output samples which is critical when audio playback or waveform generation is implemented.
The DAC conversion in SAM D microcontrollers follows the following formula.