Lab 6: Analog-to-Digital Converter
6 - 30 TMS320F2837xD Microcontroller Workshop - Analog Subsystem
Procedure
Open the Project
1. A project named Lab6 has been created for this lab exercise. Open the project by
clicking on Project Import CCS Projects. The “Import CCS Eclipse Projects”
window will open then click Browse… next to the “Select search-directory” box. Navigate
to: C:\C28x\Labs\Lab6\cpu01 and click OK. Then click Finish to import the project.
All build options have been configured the same as the previous lab exercise. The files
used in this lab exercise are:
F2837xD_GlobalVariableDefs.c
F2837xD_Headers_nonBIOS_cpu1.cmd
Note: The Dac.c and SineTable.c files are used to generate a sine waveform in the
second part of this lab exercise.
Setup ADC Initialization and Enable Core/PIE Interrupts
2. In Main_6.c add code to call the InitAdca(), InitEPwm() and InitDacb()
functions. The InitEPwm() function is used to configure ePWM2 to trigger the ADC at
a 50 kHz rate. Details about the ePWM and control peripherals will be discussed in the
next module. The InitDacb() function will be used in the second part of this lab
exercise.
3. Edit Adc.c to configure SOC0 in the ADC as follows:
• SOC0 converts input ADCINA0 in single-sample mode
• SOC0 has a 20 SYSCLK cycle acquisition window
• SOC0 is triggered by the ePWM2 SOCA
• SOC0 triggers ADCINT1 on end-of-conversion
• All SOCs run round-robin
Be sure to modify Adc.c and not F2837xD_Adc.c which is used for the ADC calibration.
4. Using the “PIE Interrupt Assignment Table” find the location for the ADC interrupt
“ADCA1” and fill in the following information:
PIE group #: # within group:
This information will be used in the next step.
5. Modify the end of Adc.c to do the following:
- Enable the “ADCA1” interrupt in the PIE (Hint: use the PieCtrlRegs structure)
- Enable the appropriate core interrupt in the IER register
6. Open and inspect DefaultIsr_6.c. This file contains the ADC interrupt service
routine. Save your work.