In embedded systems, oftentimes it is needed to generate analog outputs from a microcontroller. Examples of such include, generating audio tones, voice, music, smooth continuous waveforms, function generators, voltage reference generators, etc. Traditionally in such cases the most common techniques applied are based on Pulse Width Modulation (PWM), resistor networks and external Digital-to-Analog Converter (DAC) chips like MCP4921. The aforementioned techniques have different individual limitations and moreover require external hardware interfacing, adding complexities and extra cost to projects. XMega micros are equipped with 12 bit fast DACs apart from PWM blocks and again it proves itself to be a very versatile family of microcontrollers. In this post we will have a look into this block.
A brief overview
I used ATXMega32A4U just as always and it has only one dual channel DAC designated DACB but there are other XMega devices that have more than one DAC.
The internal block diagram of the DAC block above shows its major parts. The DAC of XMega is perhaps one of the simplest block to understand. Apart from DMA and event system interfacing, the DAC can provide reference source for the analog comparator and ADC blocks. It also has the capability to directly drive both resistive and capacitive loads (check device datasheet for limits). Just like the ADC block, the DAC block itself needs a reference source and this reference source can be both internal (internal 1.0V reference) and external (AVCC or AVREF). As stated earlier there are two independent DAC channels in the XMega32A4U and so there are two separate analog outputs (PB2 and PB3) available from this micro.
The basic formula for voltage output from the DAC is as follows:
For more Details: XMega DAC
EasyEDA: Ideas for Circuit Design, Innovation for Electronics Access
Free Circuit Design: Schematic – Simulation – PCB Layout – Gerber Viewer
JLCPCB Prototype: Only $2 for 10pcs 10×10cm, 24 hours Quick Turn, DHL Delivery in 3 days