Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
DAC Example 1 for xplain Documentation

Introduction

This example shows one way to use the Digital to Analog Converter (DAC) for outputting a sample buffer at a constant conversion rate.

Main files:

DAC driver API

The DAC driver API can be found here.

Device Info

All AVR XMEGA devices with a DAC can be used.

Description of the example

This example sets up the configured DAC (SPEAKER_DAC) to perform DA conversions on one channel (SPEAKER_DAC_CHANNEL), with output to a pin, every time it receives events in event channel 0. Timer/counter 0 on port C is used to generate the events on overflow. This setup gives a constant conversion rate.

The main loop in the example waits for the DAC channel to get ready for new data, then feeds it with a new sample from a sample buffer that contains one period of a sine wave. The DAC channel is not flagged as ready for new data until a conversion has completed, i.e., after the DAC has received an event.

Compilation Info

This software was written for the GNU GCC and IAR for AVR. Other compilers may or may not work.

Contact Information

For further information, visit Microchip.