Summary of XMega DAC
This article explores using the ATXMega32A4U microcontroller's internal 12-bit Dual Channel DAC (DACB) to generate analog outputs like audio tones and waveforms. It contrasts this internal solution with traditional external methods such as PWM or discrete DAC chips, highlighting reduced cost and complexity. The text details the DAC's reference sources (internal 1.0V, AVCC, AVREF), output pins (PB2, PB3), voltage calculation formula, and calibration options via gain/offset registers.
Parts used in the XMega Internal DAC Project:
- ATXMega32A4U Microcontroller
- Dual Channel DAC Block (DACB)
- PB2 Analog Output Pin
- PB3 Analog Output Pin
- Internal 1.0V Reference Source
- AVCC Reference Source
- AVREF External Reference Source
- Gain Error Register
- Offset Error Register
- ADC Block for Calibration

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:
Shown below are pin diagrams of both the most popular XMega A1 and A4 devices. Checkout the DAC output pin locations because these are not mentioned in the reference manual.
- What are the limitations of traditional analog generation techniques?
Traditional techniques like PWM and external DAC chips require external hardware interfacing, adding complexities and extra cost. - How many independent DAC channels does the ATXMega32A4U have?
The ATXMega32A4U has two independent DAC channels designated as DACB. - Which pins provide analog outputs from the XMega32A4U DAC?
The two separate analog outputs are available on pins PB2 and PB3. - What is the digital data value range for the 12 bit DAC?
The digital data value ranges from 0 to 4095, represented as 0x0000 to 0x0FFF. - Can the DAC drive both resistive and capacitive loads?
Yes, the DAC has the capability to directly drive both resistive and capacitive loads within device limits. - What reference sources can the XMega DAC block use?
The DAC can use an internal 1.0V reference, AVCC, or an external AVREF source. - Is DAC calibration commonly used in projects?
Calibration is seldom used unless needed for sensitive operations requiring precise data output. - How can you calibrate the DAC if you lack standard instruments?
You can use the XMega ADC block for calibration purposes if good measurement instruments are unavailable.

