Lab 6: Analog-to-Digital Converter
C2000 Microcontroller Workshop - Analog-to-Digital Converter
6 - 19
Lab 6: Analog-to-Digital Converter
Objective
The objective of this lab is to become familiar with the programming and operation of the on-chip
analog-to-digital converter. The MCU will be setup to sample a single ADC input channel at a
prescribed sampling rate and store the conversion result in a circular memory buffer.
Lab 6: ADC Sampling
ADC
ADCINA0
RESULT0
...
data
memory
CPU copies result
to buffer during
ADC ISR
ePWM2
ePWM2 triggering
ADC on period match
using SOCA trigger every
20 µs (50 kHz)
GND
+3.3 V
(GPIO20)
Toggle
(GPIO18)
connector
wire
View ADC
buffer PWM
Samples
Code Composer
Studio
Recall that there are three basic ways to initiate an ADC start of conversion (SOC):
1.
Using software
a. SOCx bit (where x = 0 to 15) in the ADC SOC Force 1 Register (ADCSOCFRC1) causes a
software initiated conversion
2.
Automatically triggered on user selectable conditions
a. CPU Timer 0/1/2 interrupt
b. ePWMxSOCA / ePWMxSOCB (where x = 1 to 7)
- ePWM underflow (CTR = 0)
- ePWM period match (CTR = PRD)
- ePWM underflow or period match (CTR = 0 or PRD)
- ePWM compare match (CTRU/D = CMPA/B)
c. ADC interrupt ADCINT1 or ADCINT2
- triggers SOCx (where x = 0 to 15) selected by the ADC Interrupt Trigger SOC Select1/2
Register (ADCINTSOCSEL1/2)
3.
Externally triggered using a pin
a. ADCSOC pin (GPIO/XINT2_ADCSOC)
One or more of these methods may be applicable to a particular application. In this lab, we will
be using the ADC for data acquisition. Therefore, one of the ePWMs (ePWM2) will be
configured to automatically trigger the SOCA signal at the desired sampling rate (ePWM period
match CTR = PRD SOC method 2b above). The ADC end-of-conversion interrupt will be used
to prompt the CPU to copy the results of the ADC conversion into a results buffer in memory.
Summary of Contents for C2000 Piccolo LaunchPad
Page 74: ...Interrupts 4 18 C2000 Microcontroller Workshop Reset and Interrupts ...
Page 100: ...Lab 5 System Initialization 5 26 C2000 Microcontroller Workshop System Initialization ...
Page 218: ...Lab 8 IQmath FIR Filter 8 42 C2000 Microcontroller Workshop Numerical Concepts ...
Page 334: ...F28069 controlCARD A 4 C2000 Microcontroller Workshop Appendix A Experimenter s Kit SW2 ...
Page 336: ...F28035 controlCARD A 6 C2000 Microcontroller Workshop Appendix A Experimenter s Kit SW2 SW3 ...