DACC (Digital-to-Analog Converter Controller) The outline of this documentation is as follows: Module Overview. Special Considerations

Similar documents
SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

USER GUIDE EDBG. Description

APPLICATION NOTE. AT07175: SAM-BA Bootloader for SAM D21. Atmel SAM D21. Introduction. Features

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 1 Introduction

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

How To Use An Atmel Atmel Avr32848 Demo For Android (32Bit) With A Microcontroller (32B) And An Android Accessory (32D) On A Microcontroller (32Gb) On An Android Phone Or

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.

AVR1900: Getting started with ATxmega128A1 on STK bit Microcontrollers. Application Note. 1 Introduction

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

SAM4 Real-Time Clock (RTC)

GCLK (Generic Clock Management) PM (Power Management) SYSCTRL (Clock Source Control) The following devices can use this module:

Atmel AVR4921: ASF - USB Device Stack Differences between ASF V1 and V2. 8-bit Atmel Microcontrollers. Application Note. Features.

AVR131: Using the AVR s High-speed PWM. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

AVR1318: Using the XMEGA built-in AES accelerator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

USER GUIDE. ZigBit USB Stick User Guide. Introduction

AVR32138: How to optimize the ADC usage on AT32UC3A0/1, AT32UC3A3 and AT32UC3B0/1 series. 32-bit Microcontrollers. Application Note.

AN3252 Application note

AVR1922: Xplain Board Controller Firmware. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE. Atmel LF-RFID Kits Overview. Atmel LF-RFID Kit. LF-RFID Kit Introduction

32-bit AVR UC3 Microcontrollers. 32-bit AtmelAVR Application Note. AVR32769: How to Compile the standalone AVR32 Software Framework in AVR32 Studio V2

APPLICATION NOTE. Atmel AT04389: Connecting SAMD20E to the AT86RF233 Transceiver. Atmel SAMD20. Description. Features

AVR125: ADC of tinyavr in Single Ended Mode. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AN3998 Application note

Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

AVR32701: AVR32AP7 USB Performance. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AT88CK490 Evaluation Kit

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE. Secure Personalization with Transport Key Authentication. ATSHA204A, ATECC108A, and ATECC508A. Introduction.

AT09333: USB Host Interface (UHI) for Communication Class Device (CDC) Introduction. Atmel Microcontrollers APPLICATION NOTE

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

AVR127: Understanding ADC Parameters. Introduction. Features. Atmel 8-bit and 32-bit Microcontrollers APPLICATION NOTE

CryptoAuth Xplained Pro

AVR106: C Functions for Reading and Writing to Flash Memory. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

APPLICATION NOTE. Atmel AVR443: Sensor-based Control of Three Phase Brushless DC Motor. Atmel AVR 8-bit Microcontrollers. Features.

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

AN AES encryption and decryption software on LPC microcontrollers. Document information

Application Note. Atmel ATSHA204 Authentication Modes. Prerequisites. Overview. Introduction

QT1 Xplained Pro. Preface. Atmel QTouch USER GUIDE

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

APPLICATION NOTE Atmel AT02509: In House Unit with Bluetooth Low Energy Module Hardware User Guide 8-bit Atmel Microcontroller Features Description

Using CryptoMemory in Full I 2 C Compliant Mode. Using CryptoMemory in Full I 2 C Compliant Mode AT88SC0104CA AT88SC0204CA AT88SC0404CA AT88SC0808CA

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

APPLICATION NOTE. AT16268: JD Smart Cloud Based Smart Plug Getting. Started Guide ATSAMW25. Introduction. Features

APPLICATION NOTE. Authentication Counting. Atmel CryptoAuthentication. Features. Introduction

System Center Virtual Machine Manager 2012 R2 Plug-In. Feature Description

Self Help Guides. Setup Exchange with Outlook

AT11805: Capacitive Touch Long Slider Design with PTC. Introduction. Features. Touch Solutions APPLICATION NOTE

Fuse MQ Enterprise Broker Administration Tutorials

Open Source Used In Cisco Instant Connect for ios Devices 4.9(1)

AVR1321: Using the Atmel AVR XMEGA 32-bit Real Time Counter and Battery Backup System. 8-bit Microcontrollers. Application Note.

RSA Two Factor Authentication

AN4646 Application note

APPLICATION NOTE. AT12405: Low Power Sensor Design with PTC. Atmel MCU Integrated Touch. Introduction

Scanning Comparator (ScanComp) Features. General Description. Input/Output Connections. When to Use a Scanning Comparator. clock - Digital Input* 1.

AT15007: Differences between ATmega328/P and ATmega328PB. Introduction. Features. Atmel AVR 8-bit Microcontrollers APPLICATION NOTE

Microsoft SharePoint

Introducing a platform to facilitate reliable and highly productive embedded developments

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.

SN 132 SNAPstick QUICK START GUIDE

General Porting Considerations. Memory EEPROM XRAM

Third Party Software Used In PLEK500 (Utility for Win) v1.x.xx.xxx

AVR353: Voltage Reference Calibration and Voltage ADC Usage. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. Atmel CryptoAuthentication Product Uses. Atmel ATSHA204. Abstract. Overview

Quest vworkspace Virtual Desktop Extensions for Linux

Application Note. 8-bit Microcontrollers. AVR272: USB CDC Demonstration UART to USB Bridge

GEO Sticky DNS. GEO Sticky DNS. Feature Description

formerly Help Desk Authority Quest Free Network Tools User Manual

Pulse Redundancy. User Guide

APPLICATION NOTE. AT05558: Wireless Manufacturing Test Kit. Atmel ATmega256RFR2. Description. Features

More Secure, Less Costly IoT Edge Node Security Provisioning

AT91SAM ARM-based Flash MCU. Application Note

Port Following. Port Following. Feature Description

AVR126: ADC of megaavr in Single Ended Mode. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

Wireless Subwoofer TI Design Tests

AVR311: Using the TWI Module as I2C Slave. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

Atmel AVR1017: XMEGA - USB Hardware Design Recommendations. 8-bit Atmel Microcontrollers. Application Note. Features.

AN11008 Flash based non-volatile storage

ES_LPC4357/53/37/33. Errata sheet LPC4357/53/37/33. Document information

Dell One Identity Cloud Access Manager How to Configure for SSO to SAP NetWeaver using SAML 2.0

Dell One Identity Cloud Access Manager How to Configure vworkspace Integration

Atmel SMART ARM Core-based Embedded Microprocessors

AN1991. Audio decibel level detector with meter driver

Dell Migration Manager for Enterprise Social What Can and Cannot Be Migrated

Designing Feature-Rich User Interfaces for Home and Industrial Controllers

Azure Multi-Factor Authentication. KEMP LoadMaster and Azure Multi- Factor Authentication. Technical Note

BlackBerry Business Cloud Services. Version: Release Notes

BlackBerry Web Desktop Manager. Version: 5.0 Service Pack: 4. User Guide

Dell Spotlight on Active Directory Server Health Wizard Configuration Guide

AVR287: USB Host HID and Mass Storage Demonstration. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

EMC6D103S. Fan Control Device with High Frequency PWM Support and Hardware Monitoring Features PRODUCT FEATURES ORDER NUMBERS: Data Brief

AN3332 Application note

Self Help Guides. Create a New User in a Domain

Adobe DNG Flat Field Plug-in (1.0) Software Notices and/or Additional Terms and Conditions

AD9125-EBZ Quick Start Guide

Transcription:

APPLICATION NOTE AT07900: SAM4 Digital-to-Analog Converter Controller (DACC) ASF PROGRAMMERS MANUAL SAM4 Digital-to-Analog Converter Controller (DACC) This driver for SAM4 (and SAM3) devices provides an interface for the configuration and management of the device's Digital-to-Analog Converter Controller functionality. The DACC offers up to two analog outputs, making it possible for the digital-toanalog conversion to drive up to two independent analog lines. The DACC supports 10-bit or 12-bit resolution. External triggers or free running mode are configurable. The DACC integrates a Sleep Mode and also connects with a PDC channel. The following peripherals are used by this module: DACC (Digital-to-Analog Converter Controller) The outline of this documentation is as follows: Prerequisites Module Overview Special Considerations Extra Information Examples API Overview

Table of Contents SAM4 Digital-to-Analog Converter Controller (DACC)... 1 Software License... 4 1. Prerequisites... 5 2. Module Overview... 6 3. Special Considerations... 7 3.1. Voltage Reference (VREF)... 7 3.2. Output Impedance... 7 4. Extra Information... 8 5. Examples... 9 6. API Overview... 10 6.1. Variable and Type Definitions... 10 6.1.1. Type dacc_rc_t... 10 6.2. Macro Definitions... 10 6.2.1. Macro DACC_MAX_DATA... 10 6.2.2. Macro DACC_RESOLUTION... 10 6.3. Function Definitions... 10 6.3.1. Function dacc_disable()... 10 6.3.2. Function dacc_disable_channel()... 10 6.3.3. Function dacc_disable_interrupt()... 11 6.3.4. Function dacc_disable_trigger()... 11 6.3.5. Function dacc_enable()... 11 6.3.6. Function dacc_enable_channel()... 12 6.3.7. Function dacc_enable_flexible_selection()... 12 6.3.8. Function dacc_enable_interrupt()... 12 6.3.9. Function dacc_get_analog_control()... 12 6.3.10. Function dacc_get_channel_status()... 13 6.3.11. Function dacc_get_interrupt_mask()... 13 6.3.12. Function dacc_get_interrupt_status()... 13 6.3.13. Function dacc_get_pdc_base()... 14 6.3.14. Function dacc_get_writeprotect_status()... 14 6.3.15. Function dacc_reset()... 14 6.3.16. Function dacc_set_analog_control()... 15 6.3.17. Function dacc_set_channel_selection()... 15 6.3.18. Function dacc_set_power_save()... 15 6.3.19. Function dacc_set_timing()... 16 6.3.20. Function dacc_set_timing()... 16 6.3.21. Function dacc_set_transfer_mode()... 16 6.3.22. Function dacc_set_trigger()... 17 6.3.23. Function dacc_set_writeprotect()... 17 6.3.24. Function dacc_write_conversion_data()... 18 6.4. Enumeration Definitions... 18 6.4.1. Enum dacc_rc... 18 7. Extra Information for Digital-to-Analog Converter Controller... 19 7.1. Acronyms... 19 7.2. Dependencies... 19 7.3. Errata... 19 7.4. Module History... 19 8. Examples for Digital-to-Analog Converter Controller... 20 8.1. Quick Start Guide for the DACC driver... 20 2

8.1.1. Use Cases... 20 8.1.2. DACC Basic Usage... 20 8.1.3. Setup Steps... 20 8.1.4. Usage Steps... 20 8.2. Digital-to-Analog Converter Sine Wave Example... 21 8.2.1. Purpose... 21 8.2.2. Requirements... 21 8.2.3. Description... 21 8.2.4. Main Files... 21 8.2.5. Compilation Information... 21 8.2.6. Usage... 21 Index... 23 Document Revision History... 24 3

Software License Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of Atmel may not be used to endorse or promote products derived from this software without specific prior written permission. 4. This software may only be redistributed and used in connection with an Atmel microcontroller product. THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 4

1. Prerequisites There are no prerequisites for this module. 5

2. Module Overview The Digital-to-Analog Converter Controller (DACC) offers up to two analog outputs, making it possible for the digital-to-analog conversion to drive up to two independent analog lines. The DACC module supports either 10 or 12-bit resolution (depending on SAM4 device). Data values to be converted are written into a common register for all channels. The DACC can be configured to operate in either external trigger or free running mode. The DACC utilizes a FIFO and can also connect with a PDC/PDCA channel, both of which help reduce processor intervention. The user application can configure DACC timings, such as Startup Time and Refresh Period. 6

3. Special Considerations 3.1 Voltage Reference (VREF) The internal conversion process of the DACC can inject transient currents into the circuitry at the device's Voltage Reference (VREF) pin. Therefore the system's Voltage Reference requires adequate decoupling in order to add stability. 3.2 Output Impedance The DACC module is not capable of driving a signal into a circuit with a low input impedance (refer to the "Analog Outputs" section in the device's datasheet). Circuits with such characteristics will require an intermediate signal buffering stage to ensure signal quality. 7

4. Extra Information For extra information, see Extra Information for Digital-to-Analog Converter Controller. This includes: Acronyms Dependencies Errata Module History 8

5. Examples For a list of examples related to this driver, see Examples for Digital-to-Analog Converter Controller. 9

6. API Overview 6.1 Variable and Type Definitions 6.1.1 Type dacc_rc_t typedef enum dacc_rc dacc_rc_t 6.2 Macro Definitions 6.2.1 Macro DACC_MAX_DATA #define DACC_MAX_DATA DAC maximum data limit (depends on DACC_RESOLUTION). 6.2.2 Macro DACC_RESOLUTION #define DACC_RESOLUTION DAC resolution in number of data bits. 6.3 Function Definitions 6.3.1 Function dacc_disable() Disable DACC. void dacc_disable( Dacc * p_dacc) Table 6-1. Parameters DACC_RC_OK on page 18 for OK. 6.3.2 Function dacc_disable_channel() Disable DACC channel. uint32_t dacc_disable_channel( Dacc * p_dacc, 10

uint32_t ul_channel) Table 6-2. Parameters? ul_channel The output channel to disable DACC_RC_OK on page 18 for OK. 6.3.3 Function dacc_disable_interrupt() Disable DACC interrupts. void dacc_disable_interrupt( Dacc * p_dacc, uint32_t ul_interrupt_mask) Table 6-3. Parameters? ul_interrupt_mask The interrupt mask 6.3.4 Function dacc_disable_trigger() Disable the DACC trigger (free run mode). void dacc_disable_trigger( Dacc * p_dacc) Table 6-4. Parameters [in, out] p_dacc Module hardware register base address pointer 6.3.5 Function dacc_enable() Enable DACC. void dacc_enable( Dacc * p_dacc) Table 6-5. Parameters 11

6.3.6 Function dacc_enable_channel() Enable DACC channel. uint32_t dacc_enable_channel( Dacc * p_dacc, uint32_t ul_channel) Table 6-6. Parameters? ul_channel The output channel to enable DACC_RC_OK on page 18 for OK. 6.3.7 Function dacc_enable_flexible_selection() Enable the flexible channel selection mode (TAG). void dacc_enable_flexible_selection( Dacc * p_dacc) In this mode the 2 bits, DACC_CDR[13:12] which are otherwise unused, are employed to select the channel in the same way as with the USER_SEL field. Finally, if the WORD field is set, the 2 bits, DACC_CDR[13:12] are used for channel selection of the first data and the 2 bits, DACC_CDR[29:28] for channel selection of the second data. Table 6-7. Parameters 6.3.8 Function dacc_enable_interrupt() Enable DACC interrupts. void dacc_enable_interrupt( Dacc * p_dacc, uint32_t ul_interrupt_mask) Table 6-8. Parameters? ul_interrupt_mask The interrupt mask 6.3.9 Function dacc_get_analog_control() 12

Get the analog control value. uint32_t dacc_get_analog_control( Dacc * p_dacc) Table 6-9. Parameters Current setting of analog control. 6.3.10 Function dacc_get_channel_status() Get the channel status. uint32_t dacc_get_channel_status( Dacc * p_dacc) Table 6-10. Parameters DACC channel status. 6.3.11 Function dacc_get_interrupt_mask() Get the interrupt mask. uint32_t dacc_get_interrupt_mask( Dacc * p_dacc) Table 6-11. Parameters The interrupt mask. 6.3.12 Function dacc_get_interrupt_status() Get the interrupt status. uint32_t dacc_get_interrupt_status( Dacc * p_dacc) 13

Table 6-12. Parameters The interrupt status. 6.3.13 Function dacc_get_pdc_base() Get PDC registers base address. Pdc * dacc_get_pdc_base( Dacc * p_dacc) Table 6-13. Parameters DACC PDC register base address. 6.3.14 Function dacc_get_writeprotect_status() Get the write protect status. uint32_t dacc_get_writeprotect_status( Dacc * p_dacc) Table 6-14. Parameters Write protect status. 6.3.15 Function dacc_reset() Reset the DACC, emulating a hardware reset. void dacc_reset( Dacc * p_dacc) Table 6-15. Parameters [out] p_dacc Module hardware register base address pointer 14

6.3.16 Function dacc_set_analog_control() Set the analog control value. uint32_t dacc_set_analog_control( Dacc * p_dacc, uint32_t ul_analog_control) Table 6-16. Parameters? ul_analog_control Analog control configuration DACC_RC_OK on page 18 for OK. 6.3.17 Function dacc_set_channel_selection() Disable flexible (TAG) mode and select a channel for DAC outputs. uint32_t dacc_set_channel_selection( Dacc * p_dacc, uint32_t ul_channel) Table 6-17. Parameters? ul_channel Channel to select DACC_RC_OK on page 18 if successful. 6.3.18 Function dacc_set_power_save() Set the power save mode. uint32_t dacc_set_power_save( Dacc * p_dacc, uint32_t ul_sleep_mode, uint32_t ul_fast_wakeup_mode) Table 6-18. Parameters? ul_sleep_mode Sleep mode configuration? ul_fast_wakeup_mode Fast wake-up mode configuration 15

DACC_RC_OK on page 18 if successful. 6.3.19 Function dacc_set_timing() Set the DACC timing. uint32_t dacc_set_timing( Dacc * p_dacc, uint32_t ul_startup, uint32_t ul_clock_divider) Table 6-19. Parameters? ul_startup Startup time selection? ul_clock_divider Clock divider for internal trigger DACC_RC_OK on page 18 for OK. 6.3.20 Function dacc_set_timing() Set DACC timings. uint32_t dacc_set_timing( Dacc * p_dacc, uint32_t ul_refresh, uint32_t ul_maxs, uint32_t ul_startup) Table 6-20. Parameters? ul_refresh Refresh period setting value? ul_maxs Max speed mode configuration? ul_startup Startup time selection DACC_RC_OK on page 18 for OK. 6.3.21 Function dacc_set_transfer_mode() Set the DACC word size transfer mode. uint32_t dacc_set_transfer_mode( 16

Dacc * p_dacc, uint32_t ul_mode) Table 6-21. Parameters [in, out] p_dacc Module hardware register base address pointer [in] ul_mode Transfer mode configuration (1 for 32 bit, 0 for 16 bit) DACC_RC_OK if successful. 6.3.22 Function dacc_set_trigger() Enable the DACC trigger and set the trigger source. uint32_t dacc_set_trigger( Dacc * p_dacc, uint32_t ul_trigger) Table 6-22. Parameters [in, out] p_dacc Module hardware register base address pointer [in] ul_trigger Trigger source number Note For more information regarding ul_trigger sources refer to the section entitled "TRGSEL: Trigger Selection" in the device-specific datasheet. DACC_RC_OK if successful. 6.3.23 Function dacc_set_writeprotect() Enable or disable write protect of DACC registers. void dacc_set_writeprotect( Dacc * p_dacc, uint32_t ul_enable) Table 6-23. Parameters? ul_enable 1 to enable, 0 to disable 17

6.3.24 Function dacc_write_conversion_data() Write data to conversion register. void dacc_write_conversion_data( Dacc * p_dacc, uint32_t ul_data) Note The ul_data could be output data or data with channel TAG when flexible mode is used. In flexible mode the 2 bits, DACC_CDR[13:12] which are otherwise unused, are employed to select the channel in the same way as with the USER_SEL field. Finally, if the WORD field is set, the 2 bits, DACC_CDR[13:12] are used for channel selection of the first data and the 2 bits, DACC_CDR[29:28] for channel selection of the second data. See also dacc_enable_flexible_selection() Table 6-24. Parameters? ul_data The data to be transferred to analog value 6.4 Enumeration Definitions 6.4.1 Enum dacc_rc Table 6-25. Members Enum value DACC_RC_OK DACC_RC_INVALID_PARAM Description Operation OK. Invalid parameter. 18

7. Extra Information for Digital-to-Analog Converter Controller 7.1 Acronyms Below is a table listing the acronyms used in this module, along with their intended meanings. Acronym CDR DMA EOC FIFO PDC PDCA QSG VREF Definition Conversion Data Register Direct Memory Access End Of Conversion First In First Out Peripheral DMA Controller Peripheral DMA Controller (SAM4L) Quick Start Guide Voltage Reference 7.2 Dependencies This driver has the following dependencies: None 7.3 Errata There are no errata related to this driver. 7.4 Module History An overview of the module history is presented in the table below, with details on the enhancements and fixes made to the module since its first release. The current version of this corresponds to the newest version in the table. Changelog Initial document release 19

8. Examples for Digital-to-Analog Converter Controller This is a list of the available Quick Start Guides (QSGs) and example applications for SAM4 Digital-to-Analog Converter Controller (DACC). QSGs are simple examples with step-by-step instructions to configure and use this driver in a selection of use cases. Note that QSGs can be compiled as a standalone application or be added to the user application. Quick Start Guide for the DACC driver Digital-to-Analog Converter Sine Wave Example 8.1 Quick Start Guide for the DACC driver This is the quick start guide for the SAM4 Digital-to-Analog Converter Controller (DACC), with step-by-step instructions on how to configure and use the driver for a specific use case. The code examples can be copied into e.g. the main application loop or any other function that will need to control the AST module. 8.1.1 Use Cases DACC Basic Usage 8.1.2 DACC Basic Usage This use case will demonstrate how to initialize the DACC module in half word mode. 8.1.3 Setup Steps 8.1.3.1 Prerequisites This module requires the following service: System Clock Management (sysclock) 8.1.3.2 Setup Code Add this to the main loop or a setup function: 8.1.3.3 Workflow 1. Reset the DACC module: 2. Set half word transfer mode: 3. Set the timing, sleep mode (device specific) and enable the channel: 8.1.4 Usage Steps 8.1.4.1 Usage Code We can get the DACC status by: 20

We can check the DACC is ready for new data by: } We can update the DACC data by: uint32_t dac_val = 1000; 8.2 Digital-to-Analog Converter Sine Wave Example 8.2.1 Purpose This example demonstrates how to use the DACC driver to generate a sine wave. 8.2.2 Requirements This example can be used with SAM4 evaluation kits such as the SAM4S Xplained, the SAM4N Xplained Pro, and other evaluation kits. Refer to the list of kits available for the actual device on http://www.atmel.com. 8.2.3 Description This application demonstrates how to use the DACC in free running mode. The example allows the frequency and amplitude of a generated sine wave to be adjusted. The sine wave's frequency can be adjusted between 200Hz and 3kHz while its peak amplitude can be adjusted between 100 to 1023 (for devices with 10-bit resolution) and 4095 (for devices with 12-bit resolution). The example can also generate a full amplitude square wave for reference. The sine wave can be monitored by connecting an oscilloscope to the DACC channel's output pin used by the example. Refer to dac_sinewave_example_pin_defs in the evaluation kit specific header file conf_dacc_sinewave_example.h for the pin to monitor. 8.2.4 Main Files dacc.c: Digital-to-Analog Converter Controller driver dacc.h: Digital-to-Analog Converter Controller driver header file sinewave_example.c: Digital-to-Analog Converter Controller example application 8.2.5 Compilation Information 8.2.6 Usage This software is written for GNU GCC and IAR Embedded Workbench for Atmel. Other compilers may or may not work. 1. Build the program and download it into the evaluation board. 2. On the computer, open and configure a terminal application (e.g., HyperTerminal on Microsoft Windows ) with these settings: 115200 baud 8 bits of data 21

No parity 1 stop bit No flow control 3. In the terminal window, the following text should appear (values depend on the board and chip used): * -- DAC Sinewave Example xxx -- * -- xxxxxx-xx * -- Compiled: xxx xx xxxx xx:xx:xx -- * ======== Menu Choices for this example ======== * -- 0: Set frequency (200Hz-3kHz). * -- 1: Set amplitude (100-4095). * -- i: Display present frequency and amplitude. * -- w: Switch to full amplitude square wave or back. * -- m: Display this menu. * ------------ Current configuration ------------ * -- DACC channel: 0 * -- Amplitude : 2047 * -- Frequency : 1000 * -- Wave : SINE * =============================================== 4. Use this menu to alter the waveform's characteristics. 22

Index E Enumeration Definitions dacc_rc, 18 F Function Definitions dacc_disable, 10 dacc_disable_channel, 10 dacc_disable_interrupt, 11 dacc_disable_trigger, 11 dacc_enable, 11 dacc_enable_channel, 12 dacc_enable_flexible_selection, 12 dacc_enable_interrupt, 12 dacc_get_analog_control, 12 dacc_get_channel_status, 13 dacc_get_interrupt_mask, 13 dacc_get_interrupt_status, 13 dacc_get_pdc_base, 14 dacc_get_writeprotect_status, 14 dacc_reset, 14 dacc_set_analog_control, 15 dacc_set_channel_selection, 15 dacc_set_power_save, 15 dacc_set_timing, 16, 16 dacc_set_transfer_mode, 16 dacc_set_trigger, 17 dacc_set_writeprotect, 17 dacc_write_conversion_data, 18 M Macro Definitions DACC_MAX_DATA, 10 DACC_RESOLUTION, 10 T Type Definitions dacc_rc_t, 10 23

Document Revision History Doc. Rev. Date Comments 42293A 05/2014 Initial document release 24

Atmel Corporation 1600 Technology Drive, San Jose, CA 95110 USA T: (+1)(408) 441.0311 F: (+1)(408) 436.4200 www.atmel.com 2014 Atmel Corporation. All rights reserved. / Rev.: Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Windows is a registered trademark of Microsoft Corporation in U.S. and or other countries. Other terms and product names may be trademarks of others. Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.