Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ADC Example
 

Purpose

The ADC example demonstrates how to use ADC/ADC12B peripheral with several modes.

Requirements

This example can be used on any SAM3/4 boards.

ADVREF must be set to 3300 mv in order to enable full scale measurement of the potentiometer. Please refer to the board schematics for ADVREF jumper configuration.

We use one push button for ADTGR, so please connect ADTRG to relative button pin

  • BUTTON – TRIGGER
  • BP2(PB3) – ADTRG(PA8)

Description

This application shows how to use the ADC using the several modes: with/without PDC, several types of trigger (Software, ADTRG, Timer, etc.), gain and offset selection, using sequencer. Users can select different modes by configuration menu in the terminal.

Note
The sequence number allowed for sam3s8 is 0 up to 7, so the channel 15 used for TempSensor is not allowed to be set as the sequencer. Two times of capture on channel 5 are used instead in the user sequence mode demo.

Usage

  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 bauds
    • 8 bits of data
    • No parity
    • 1 stop bit
    • No flow control
  3. In the terminal window, the following text should appear (values depend on the board and the chip used):
    -- ADC Example xxx --
    -- xxxxxx-xx
    -- Compiled: xxx xx xxxx xx:xx:xx --
    =========================================================
    Menu: press a key to change the configuration.
    ---------------------------------------------------------
    [X] 0: Set ADC trigger mode: Software.
    [ ] 1: Set ADC trigger mode: ADTRG.
    [ ] 2: Set ADC trigger mode: Timer TIOA.
    [ ] 3: Set ADC trigger mode: PWM Event Line.
    [ ] 4: Set ADC trigger mode: Free run mode.
    [E] T: Enable/Disable to transfer with PDC.
    [D] S: Enable/Disable to use user sequence mode.
    [D] P: Enable/Disable ADC power save mode.
    [D] G: Enable/Disable to set gain=2 for potentiometer channel.
    [D] O: Enable/Disable offset for potentiometer channel.
    Q: Quit configuration and start ADC.
    =========================================================
  4. The application will output converted value to HyperTerminal and display a menu for users to set different modes.