TMS320F28335 Library  1.0
Documentation
ePWM

Configure a GPIO pin as ePWM. Set frequency and start PWM signal with specific dutycycle.

Min. frequency: 1145 Hz (2289 Hz in Up- or Down-Count-Mode)
Max. frequency: 1 MHz

Min. dutycycle: 0
Max. dutycycle: 100


ePWMxA ePWMxB
ePWM1 GPIO0 GPIO1
ePWM2 GPIO2 GPIO3
ePWM3 GPIO4 GPIO5
ePWM4 GPIO6 GPIO7
ePWM5 GPIO8 GPIO9
ePWM6 GPIO10 GPIO11

Initialisation of ePWM Pins

  • ePWMxA and ePWMxB pins can be configured and signals can be set independently.
  • ePWMxA and ePWMxB pins can be driven with different dutycycles but not with different frequencies.
    --> Configuring a pin as ePWM output with a frequency will affect both pins of the respective PWM-module: ePWMxA and ePWMxB.
init_ePWM(GPIO0, 125000); //configuring ePWM1A with 125 kHZ
init_ePWM(GPIO1, 100000); //configuring ePWM1B with 100 kHz
  • ePWM1A and ePWM1B will both run at 100 kHz because they belong to one PWM-module (which was configured with 100 kHz)
  • first configuration is overwritten
  • both pins need to be configured to ensure their configuration as ePWM pins

If you want to use both ePWM pins of one module, ePWMxA and ePWMxB, configure both with the same frequency to prevent misconfiguration:

init_ePWM(GPIO0, 100000); //configuring ePWM1A with 100 kHZ
init_ePWM(GPIO1, 100000); //configuring ePWM1B with 100 kHz

Code example

#include "global_defines.h" //Include global_defines.h
#include "system_controls/system_controls.h" //Include module of system controls
#include "epwm/epwm.h" //Include module of epwm
void main(void){
int result = 0; //Optional: can be used to check return values of functions
setSystemControls(); //Call setSystemControls() function
result = init_ePWM(GPIO0, 100000); //Init GPIO0 pin as ePWM1A pin with a frequency of 100 kHz. Returns result of operation
result = ePWM_start(GPIO0, 50); //Start ePWM1A output signal on GPIO0 with a Dutycycle of 50%. Returns result of operation
while(1){
//Endless loop
}
result = ePWM_stop(GPIO0); //Stop ePWM1A output signal on GPIO0. GPIO0 is set to low. Returns result of operation
}

Documented C-Code of module:

epwm


Detailed description in Technical Reference Manual:

Technical_Reference_Manual

init_ePWM
int16 init_ePWM(Uint16 gpio, Uint32 frequency)
Configuration of GPIO as epwm.
Definition: epwm.c:20
ePWM_start
int16 ePWM_start(Uint16 gpio, Uint16 dutycycle)
Start ePWM signal on pin.
Definition: epwm.c:80
epwm.h
Header file for ePWM module.
ePWM_stop
int16 ePWM_stop(Uint16 gpio)
Stop ePWM signal on pin.
Definition: epwm.c:133
global_defines.h
Header file for global defines.
setSystemControls
void setSystemControls(void)
Configuration of system control register.
Definition: system_controls.c:13
system_controls.h
Header file for System Controls module.