Lab 7: Control Peripherals
TMS320F2837xD Microcontroller Workshop - Control Peripherals 7 - 51
F2837xD_GlobalVariableDefs.c
F2837xD_Headers_nonBIOS_cpu1.cmd
Note: The ECap.c file will be added and used with eCAP1 to detect the rising and falling
edges of the waveform in the second part of this lab exercise.
Setup Shared I/O and ePWM1
2. Edit Gpio.c and adjust the shared I/O pin in GPIO0 for the PWM1A function.
3. In EPwm.c, setup ePWM1 to implement the PWM waveform as described in the objective
for this lab exercise. The following registers need to be modified: TBCTL (set clock
prescales to divide-by-1, no software force, sync and phase disabled), TBPRD, CMPA,
CMPCTL (load on 0 or PRD), and AQCTLA (set on up count and clear on down count for
output A). Software force, deadband, PWM chopper and trip action has been disabled.
(Hint – notice the last steps enable the timer count mode and enable the clock to the
ePWM module). Directly make use of the global variable names for the TBPRD and
CMPA values which have been set using #define in the beginning of Lab.h file. Within
the Project Explorer window, the Lab.h file is located in the include folder under
/Lab_common/include. (As a challenge, you could calculate the values for TBPRD and
CMPA). Notice that ePWM2 has been initialized earlier in the code for the ADC lab
exercise. Save your work.
Build and Load
4. Click the “Build” button and watch the tools run in the Console window. Check for
errors in the Problems window.
5. Click the “Debug” button (green bug). A Launching Debug Session window will open.
Select only CPU1 to load the program on (i.e. uncheck CPU2), and then click OK. Then
the CCS Debug perspective view should open, the program will load automatically, and
you should now be at the start of main(). If the device has been power cycled since the
last lab exercise, be sure to configure the boot mode to EMU_BOOT_SARAM using the
Scripts menu.
Run the Code – PWM Waveform
6. Using a jumper wire, connect the PWM1A (header J4, pin #40) to ADCINA0 (header J3,
pin #30) on the LaunchPad. Refer to the following diagram for the pins that need to be
connected.