Vous êtes sur la page 1sur 14

Tiva C ADC

By James Cockrell and Justin Loveless

Overview of Analog-Digital Converter
Turns an analog voltage into a digital value
Used for sensor measurement
Can be triggered with either SWIs or HWIs
TM4C ADC Specs
Reference voltages:
VREFP tied to 3.3V on the Launchpad.
VREFN tied to ground on the Launchpad.
Range & Resolution
Range = 0 4095
Resolution = 3.3V / 4096 = 8.05 mV (p. 803)
Max Sampling Speed = 1 million samples/second
Hardware Averaging
Averages 4 samples in hardware during conversion
Differential Sampling
Sample the difference between two inputs
Internal Temp Sensor
Can be sampled for chip temp
ADC0 and ADC1
There are two 12 bit ADCs
All input channels and triggers are shared by both ADCs
Pick sequencers based on how many samples you want
For our example we only need one sample
Sequencer Number of Samples Depth of FIFO
SS3 1 1
SS2 4 4
SS1 4 4
SS0 8 8
Analog input pins (p.795)
Pin Name Pin Number Pin Assignment
These pins can be used as analog
AIN0 6 PE3
inputs if their alternate functions
AIN1 7 PE2
are enabled
AIN2 8 PE1
AIN3 9 PE0
AIN4 64 PD3
AIN5 63 PD2
AIN6 62 PD1
AIN7 61 PD0
AIN8 60 PE5
AIN9 59 PE4
AIN10 58 PB4
AIN11 57 PB5
Triggers (p. 793)
Potential triggers include
Controller (software)
Analog Comparators
Nothing (continuous samples)
Our example will use a software as the trigger
Example setup

Its actually that simple!


Tiva C
PE3 Pot

Example ADC Code
1. Set up clock for 40 MHz

2. Enable peripheral ADC0, then reset it to apply changes

3. Disable ADC0 sequencer 3

4. Configure ADC sequencer

5. Configure steps for sequences

6. Enable peripheral GPIO port E

Example ADC Code

1. Activate PE3s alternate function (AIN0)

2. Set up interrupt handler for ADC0 sequencer 3

3. Enable interrupts for ADC0 sequencer 3

4. Re-enable ADC0 sequencer 3

5. Enable global interrupts

6. Post request for ADC conversion (in a loop)

Example ADC Code (ISR handler)

1. Clear interrupt flag for ADC0 Sequencer 3

2. Wait until conversion is done

3. Read data, and process it

Libraries to include
From the TivaWare peripheral drivers:

File path to TivaWare libraries and examples:

Chapter 5
Explains the API functions
Tiva C peripheral library and examples download site
Overview and specifications