Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.
C6747 EHRPWM Example
The software discussed on this site is available for download, but is no longer being actively developed. This wiki is in maintenance mode and the software is supported on C67x Single core DSP E2E forum
This is an example project for the C6747 EHRPWM module (although this can be used on the OMAP-L137's DSP as well). This example serves to function as a basic starting point for a DSP/BIOS-based project which utilizes the PWM module. The EHRPWM is configured to output a shifting duty cycle which is modified via interrupts at the end of each PRD.
While this code should be easily adaptable to something other than what is listed below the hardware and software listed below was used to verify the project.
This project was built and tested using the OMAP-L137/C6747 EVM in addition to the OMAP-L137 EVM Prototype Board. The prototype board was used to allow for access to the EPWM0A output pin for measurement/verification.
NOTE that much of the initialization code was copied from the EVM GEL file and modified into cslr code.
This project (downloaded here:C6747_EHRPWM_interrupt_bios.zip) contains the following source files:
as well as the BIOS configuration file
NOTE that during the build process several other BIOS-related files will be generated including C6747_EHRPWM_interruptcfg.cmd. Do not be alarmed if you receive a missing file dialog box the first time you open the project. Simply rebuild and the remaining files should populate themselves in the project folder.
This file contains the main function as well as the ISR function EhrpwmIsr(). Main() simply calls into Peripheral_Init() which then initializes all necessary peripherals (see below). The EhrpwmIsr() simply acknowledges the EHRPWM interrupt by clearing a bit, then either increments or decrements the CMPA value. This shifting CMPA value changes the duty cycle of the output. When the CMPA value reaches a pre-defined min or max value the output is then turned the opposite direction.
This file contains all of the peripheral initialization code that this project requires.
NOTE that if you plan on plugging this code into another project or using it on something other than the C6747/OMAP-L137 EVM that you may need to modify or remove some pieces of this code's initialization. For example, the PLL initialization may need to change for custom hardware or the PINMUX registers could require additional modification so that the appropriate pins are configured.
This file is responsible for:
- Configuring the PLL
- Powering up the necessary peripherals (PSC0 and PSC1)
- Configuring the necessary pins (PINMUX)
- Enabling up interrupts (IER)
- Initializing EHRPWM0
Each function in this file need only be called a single time at system startup.
This file holds all of the #includes each file needs as well as some symbol definitions.
Setting up the Prototype Board
The prototype board ships almost completely unpopulated, so some simple work is necessary. First off, the J1 header must be populated to as to gain access to the EPWM0A pin (J1.29). Once this header is populated, simply flip SW1.4 ON so as to route the EPWM0A pin to the header. Finally, plug the prototype board onto the C6747 EVM.
Rebuilding the Project
The project was built assuming default installation for the PSP (C:\Program Files\Texas Instruments\pspdrivers_01_20_00\packages). If the PSP is installed elsewhere you will need to modify the Include Search Path inside the Project->Build Options->Compiler tab->Preprocessor Category to point to the proper location.
NOTE that the cslr_ehrpwm.h header includes 5 multiple redefinition warnings. This has been submitted as a bug #SDOCM00060340. For the purposes of this project it poses no risk to proper operation.
Now load the .out file to the DSP and execute the code. You should now be able to see the EPWM0A output 'shifting' left and right across an oscilloscope.
You can download a movie file (.m4v extension) which illustrates the shifting of the EPWM0A output.