Atmel Software Framework

Quickstart guide for ADC driver

This is the quickstart guide for the ADC2 driver with step-by-step instructions on how to configure and use the driver in a selection of use cases.

The use cases contain several code fragments. The code fragments in the steps for setup can be copied into a custom initialization function, while the steps for usage can be copied into, e.g., the main application function.

Basic use case

In this basic use case, the ADC module and single channel are configured for:

  • 10 -bit resolution
  • ADC clock frequency is 6MHz
  • Start Up Time is 64 periods ADC clock
  • Tracking Time is 3 periods of ADC clock
  • Transfer Period field shall be programmed with 2 as datasheet said
  • The controller converts channels in a simple numeric order
  • Appends the channel number to the conversion result in AFE_LDCR register
  • Single Trigger is optional to get an averaged value
  • Software triggering of conversions
  • Single channel measurement
  • ADC_CHANNEL_1 of ADC as input

Prerequisites

  1. System Clock Management (Sysclock)

Setup steps

Example code

Add to application C-file:

Workflow

  1. Enable ADC Module:
  2. Get the ADC default configurations:
  3. Initialize the ADC Module:
  4. Configure conversion trigger and free run mode:
  5. Enable Channel:

Usage steps

Example code

Add to, e.g., main loop in application C-file:

Workflow

  1. Start ADC conversion on channel:
  2. Wait for the conversion over:
  3. Get the conversion result: