Lab 7: Control Peripherals
7 - 48 C2000 Microcontroller Workshop - Control Peripherals
Acquisition Buffer Size 50
DSP Data Type 16-bit unsigned integer
Sampling Rate (Hz) 50000
Start Address AdcBuf
Data Plot Style Bar
FFT Order 10
Select OK to save the graph options.
12. On the plot window, hold the mouse left-click key and move the marker line to observe
the frequencies of the different magnitude peaks. Do the peaks occur at the expected
frequencies?
13. Fully halt the CPU (real-time mode) by using the Script function: Scripts
Realtime Emulation Control Full_Halt.
Setup eCAP1 to Measure Width of Pulse
The first part of this lab exercise generated a 2 kHz, 25% duty cycle symmetric PWM
waveform which was sampled with the on-chip analog-to-digital converter and displayed
using the graphing feature of Code Composer Studio. Next, eCAP1 will be setup to detect
the rising and falling edges of the waveform. This information will be used to determine the
period and duty cycle of the waveform. The results of this step will be viewed numerically in
a memory window and can be compared to the results obtained using the graphing features of
Code Composer Studio.
14. Switch to the “CCS Edit Perspective” view by clicking the CCS Edit icon in the upper
right-hand corner. Add the following file to the project from
C:\C28x\Labs\Lab7\Files:
ECap_7_8_9_10_12.c
Check your files list to make sure the file is there.
15. In Main_7.c, add code to call the InitECap() function. There are no passed
parameters or return values, so the call code is simply:
InitECap();
16. Edit Gpio.c and adjust the shared I/O pin in GPIO5 for the ECAP1 function.
17. Open and inspect the eCAP1 interrupt service routine (ECAP1_INT_ISR) in the file
DefaultIsr_7.c. Notice that PwmDuty is calculated by CAP2 – CAP1 (rising to
falling edge) and that PwmPeriod is calculated by CAP3 – CAP1 (rising to rising edge).
18. In ECap_7_8_9_10_12.c, setup eCAP1 to calculate PWM_duty and PWM_period.
The following registers need to be modified: ECCTL2 (continuous mode, re-arm disable,
and sync disable), ECCTL1 (set prescale to divide-by-1, configure capture event polarity
without reseting the counter), and ECEINT (enable desired eCAP interrupt).