Anda di halaman 1dari 14

Tiva C ADC

By James Cockrell and Justin Loveless


Overview of Analog-Digital Converter
(ADC)
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
Sequencers
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)
Timers
Analog Comparators
PWM
GPIO
Nothing (continuous samples)
Our example will use a software as the trigger
Example setup

Its actually that simple!

3.3V

Tiva C
PE3 Pot

GND
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:


C:\ti\TivaWare_C_Series-2.1.1.71\examples\peripherals
Questions?
Resources
https://engineering.purdue.edu/ece477/Archive/2014/Spring/S14-
Grp1/docs/software/LM4F-LaunchPad-05%20-%20ADC.pdf
Chapter 5
http://www.ti.com/lit/ug/spmu298a/spmu298a.pdf
Explains the API functions
http://software-dl.ti.com/tiva-c/SW-TM4C/latest/index_FDS.html
Tiva C peripheral library and examples download site
http://software-dl.ti.com/trainingTTO/trainingTTO_public_sw/G
SW-TM4C123G-LaunchPad/TM4C123G_LaunchPad_Workshop_Workbook.pd
f
Overview and specifications

Anda mungkin juga menyukai