Epwm.c File Reference

#include "Epwm.h"
#include "cpu.h"
#include "gpio.h"

Go to the source code of this file.

Functions

void BindPWMOutputs (void)
static void CalculatePrescalerBits (Uint16 tpwm_us, Uint16 *hspClkDiv, Uint16 *clkDiv)
 Calculates prescaler bits for a given pwm period.
void InitSinglePWMOutput (void(*interruptFCN)(void), ePWMenum PWM, Uint16 tpwm_us, PWMMODE pwmMode, PWMCARRIER pwmCarrier, PWMMODULATION modulation, INTSEL intSel, SWITCHLOGIC switchLogic)
void InitComplementaryPWMOutput (void(*interruptFCN)(void), ePWMenum PWM, Uint16 tpwm_us, Uint16 db_us, PWMMODE pwmMode, PWMCARRIER pwmCarrier, PWMMODULATION modulation, INTSEL intSel, SWITCHLOGIC switchLogic)
void Init3phPWM (void(*interruptFCN)(void), EPWMX epwmX, Uint16 tpwm_us, Uint16 db_us, PWMCARRIER pwmCarrier, PWMMODULATION modulation, INTSEL intSel, _iq vBus, ePWMSOC soc, SWITCHLOGIC switchLogic)
void ConfigurePWMLeg (volatile struct EPWM_REGS *pwmPtr, PHSEN master, Uint16 tpwm_us, Uint16 db_us, PWMCARRIER pwmCarrier, PWMMODULATION modulation, unsigned int polSel)
void AddEventTrigger (volatile struct EPWM_REGS *pwmPtr, ePWMSOC soc, SOCTrigger trigger)
void InitPWMPeripheralClocks (void)
 Init clocks on PWM inputs EPWMA/B depending on the configuration stored in pwmConf.epwmX.
void InitPWMAPeripheralClocks (void)
 Init clocks on PWM inputs EPWMA.
void InitPWMBPeripheralClocks (void)
 Init clocks on PWM inputs EPWMB.
void InitEPWMGpio (ePWMenum ePWM)
void InitTzGpio (void)

Variables

struct PWM3phConfiguration pwmConf
struct PWM3phConfiguration pwmAConf
struct PWM3phConfiguration pwmBConf
const Uint16 _offsetPWM
struct EPWM_REGS * ePWM []
 acess pointers to pwm configuration registers
volatile Uint16 * cmpPtr [PWM_OUTPUTS_SIZE]
 fast access to EPWM comparison registers
int MEP_ScaleFactor [PWM_CH] = {0,0,0,0,0}
int MEP_SF1
int MEP_SF2
int MEP_SF3
int MEP_SF4
int MEP_SF5
int MEP_SF6
static const Uint16 clkMat [] = {1, 2, 4, 8, 32, 64, 128}
static const Uint16 hspClkMat [] = {1, 2, 4, 6, 8, 10, 12}
static const Uint16 hspClkIndxMat []
static const Uint16 lspClkIndxMat []

Function Documentation

void AddEventTrigger ( volatile struct EPWM_REGS *  pwmPtr,
ePWMSOC  soc,
SOCTrigger  trigger 
)

Selects where the Start of Conversion (SOC) signal is generated

Parameters:
pwmPtr,: Pointer to EPWM_REGS register for the configuration
soc,: Which sequencer is triggered (SOCNULL/SOCA/SOCB)
trigger,: 
  • EvTBeqZERO trigger A/D on zero
  • EvTBeqPRD trigger A/D of period
  • EvTBCNTeqCMPAI trigger A/D on compare math EPWMA (increasing)
  • EvTBCNTeqCMPAD trigger A/D on compare math EPWMA (decreasing)
  • EvTBCNTeqCMPBI trigger A/D on compare math EPWMB (increasing)
  • EvTBCNTeqCMPBD trigger A/D on compare math EPWMB (decreasing)

Definition at line 378 of file Epwm.c.

void BindPWMOutputs ( void   ) 

Definition at line 69 of file Epwm.c.

static void CalculatePrescalerBits ( Uint16  tpwm_us,
Uint16 *  hspClkDiv,
Uint16 *  clkDiv 
) [inline, static]

Calculates prescaler bits for a given pwm period.

Definition at line 103 of file Epwm.c.

void ConfigurePWMLeg ( volatile struct EPWM_REGS *  pwmPtr,
PHSEN  master,
Uint16  tpwm_us,
Uint16  db_us,
PWMCARRIER  pwmCarrier,
PWMMODULATION  modulation,
unsigned int  polSel 
)

Configure two switches to work in complementary mode

Parameters:
pwmPtr,: Pointer to EPWM_REGS register for the configuration of the switches pair
master,: MASTERPWM/SLAVEPWM. Selects if the clocking signal is generated by the configured output or is passed externally.
tpwm_us,: switching period in us
db_us,: dead time value in us
pwmCarrier,: select SAWTOOTH or TRIANGLE carrier
modulation,: SYMMETRICAL/ASYMMETRICAL. If symmetrical, comparison values are updated when the counter reaches 0. If asymmetrical, comparison values are updated both at 0 and period of the counter
polSel,: Polarity selection for dead time generation (DB_ACTIVE_LOC/DB_ACTIVE_HIC)

Definition at line 332 of file Epwm.c.

void Init3phPWM ( void(*)(void)  interruptFCN,
EPWMX  epwmX,
Uint16  tpwm_us,
Uint16  db_us,
PWMCARRIER  pwmCarrier,
PWMMODULATION  modulation,
INTSEL  intSel,
_iq  vBus,
ePWMSOC  soc,
SWITCHLOGIC  switchLogic 
)

Intializes a set of EPWM outputs to drive a three phase inverter

Parameters:
interruptFCN,: pointer to ISR executed when intSel condition is reached. If 0, no function is called
epwmX,: Selection of PWM input to be configured (PWM1...PWM6)
tpwm_us,: switching period in us
db_us,: dead time value in us
pwmCarrier,: select SAWTOOTH or TRIANGLE carrier
modulation,: SYMMETRICAL/ASYMMETRICAL. If symmetrical, comparison values are updated when the counter reaches 0. If asymmetrical, comparison values are updated both at 0 and period of the counter
intSel,: CTR_ZERO/CTR_PRD. Call the ISR when the counter reach 0 or when the counter reach the period.
vBus,: DC bus voltage in V (
Todo:
: Eliminate this parameter)
Parameters:
soc,: SOCNULL/SOCA/SOCB. Generates a start of conversion trigger for none, A or B sequencer respectively
switchLogic,: POS_LOGIC/NEG_LOGIC. Select logic for the switches
Examples:
TIMotorLIBExample2/main.c, TIMotorLIBExample3/main.c, TIMotorLIBExampleHrdw/main.c, and TIMotorLIBExampleSw/main.c.

Definition at line 247 of file Epwm.c.

void InitComplementaryPWMOutput ( void(*)(void)  interruptFCN,
ePWMenum  PWM,
Uint16  tpwm_us,
Uint16  db_us,
PWMMODE  pwmMode,
PWMCARRIER  pwmCarrier,
PWMMODULATION  modulation,
INTSEL  intSel,
SWITCHLOGIC  switchLogic 
)

Intializes a given EPWM pair in complementary mode

Parameters:
interruptFCN,: pointer to ISR executed when intSel condition is reached. If 0, no function is called
PWM,: Selection of PWM input to be configured (PWM1...PWM6)
tpwm_us,: switching period in us
db_us,: dead time value in us
pwmMode,: normal mode (16 bits) or high resolution (
Todo:
) (32 bits)
Parameters:
pwmCarrier,: select SAWTOOTH or TRIANGLE carrier
modulation,: SYMMETRICAL/ASYMMETRICAL. If symmetrical, comparison values are updated when the counter reachs 0. If asymmetrical, comparison values are updated both at 0 and period of the counter
intSel,: CTR_ZERO/CTR_PRD. Call the ISR when the counter reach 0 or when the counter reach the period.
switchLogic,: POS_LOGIC/NEG_LOGIC. Select logic for the switches

Definition at line 201 of file Epwm.c.

void InitEPWMGpio ( ePWMenum  PWM  ) 

Configure needed GPIO ports to be used by EPWM outputs. Affected GPIO inputs are: EPWM1: GPIO0, GPIO1 EPWM2: GPIO2, GPIO3 EPWM3: GPIO4, GPIO5 EPWM4: GPIO6, GPIO7 EPWM5: GPIO8, GPIO9 EPWM6: GPIO10, GPIO11 Actions taken:

  • Enable internal pull-up (GpioCtrlRegs.GPAPUD.bit.GPIOX=0)
  • Configure GPIOX as EPWM (GpioCtrlRegs.GPAMUX1.bit.GPIOX=1)
    Parameters:
    PWM is the pwm input to be used

Definition at line 444 of file Epwm.c.

void InitPWMAPeripheralClocks ( void   ) 

Init clocks on PWM inputs EPWMA.

Definition at line 416 of file Epwm.c.

void InitPWMBPeripheralClocks ( void   ) 

Init clocks on PWM inputs EPWMB.

Definition at line 430 of file Epwm.c.

void InitPWMPeripheralClocks ( void   ) 

Init clocks on PWM inputs EPWMA/B depending on the configuration stored in pwmConf.epwmX.

Definition at line 395 of file Epwm.c.

void InitSinglePWMOutput ( void(*)(void)  interruptFCN,
ePWMenum  PWM,
Uint16  tpwm_us,
PWMMODE  pwmMode,
PWMCARRIER  pwmCarrier,
PWMMODULATION  modulation,
INTSEL  intSel,
SWITCHLOGIC  switchLogic 
)

Initializes a given EPWM

Parameters:
interruptFCN,: pointer to ISR executed when intSel condition is reached. If 0, no function is called
PWM,: Selection of PWM input to be configured (PWM1...PWM6)
tpwm_us,: switching period in us
pwmMode,: normal mode (16 bits) or high resolution (
Todo:
) (32 bits)
Parameters:
pwmCarrier,: select SAWTOOTH or TRIANGLE carrier
modulation,: SYMMETRICAL/ASYMMETRICAL. If symmetrical, comparison values are updated when the counter reaches 0. If asymmetrical, comparison values are updated both at 0 and period of the counter
intSel,: CTR_ZERO/CTR_PRD. Call the ISR when the counter reach 0 or when the counter reach the period.
switchLogic,: POS_LOGIC/NEG_LOGIC. Select logic for the drived switch

Definition at line 122 of file Epwm.c.

void InitTzGpio ( void   ) 

Configure needed GPIO ports to be used by EPWM Trip-zone submodule. Affected GPIO inputs are: TZ1: GPIO12 TZ2: GPIO13 TZ3: GPIO14 TZ4: GPIO15 TZ5: GPIO16 TZ6: GPIO17 Actions taken:

  • Enable internal pull-up (GpioCtrlRegs.GPAPUD.bit.GPIOX=0)
  • Asynch input GPIOX (GpioCtrlRegs.GPAQSEL1.bit.GPIOX = 3)
  • Configure GPIOX as TZX (GpioCtrlRegs.GPAMUXn.bit.GPIOX = 1)

Definition at line 479 of file Epwm.c.


Variable Documentation

const Uint16 _offsetPWM
const Uint16 clkMat[] = {1, 2, 4, 8, 32, 64, 128} [static]

Definition at line 55 of file Epwm.c.

volatile Uint16* cmpPtr[PWM_OUTPUTS_SIZE]

fast access to EPWM comparison registers

Definition at line 35 of file Epwm.c.

struct EPWM_REGS* ePWM[]
Initial value:
 {&EPwm1Regs, &EPwm2Regs, &EPwm3Regs, &EPwm4Regs,
&EPwm5Regs, &EPwm6Regs}

acess pointers to pwm configuration registers

Definition at line 33 of file Epwm.c.

const Uint16 hspClkIndxMat[] [static]
Initial value:
 {0, 1, 2, 3, 4, 5, 6, 4, 5, 6, 4, 5, 6,
          4, 5, 6, 2, 3, 4, 5, 6, 4, 5, 6, 4, 5, 6}

Definition at line 59 of file Epwm.c.

const Uint16 hspClkMat[] = {1, 2, 4, 6, 8, 10, 12} [static]

Definition at line 57 of file Epwm.c.

const Uint16 lspClkIndxMat[] [static]
Initial value:
 {0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2,
          3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6}

Definition at line 62 of file Epwm.c.

int MEP_ScaleFactor[PWM_CH] = {0,0,0,0,0}

Definition at line 36 of file Epwm.c.

int MEP_SF1

Definition at line 37 of file Epwm.c.

int MEP_SF2

Definition at line 37 of file Epwm.c.

int MEP_SF3

Definition at line 37 of file Epwm.c.

int MEP_SF4

Definition at line 37 of file Epwm.c.

int MEP_SF5

Definition at line 37 of file Epwm.c.

int MEP_SF6

Definition at line 37 of file Epwm.c.

Definition at line 30 of file Epwm.c.

Definition at line 31 of file Epwm.c.

Deprecated:
: Not use pwmConf in new projects. Instead, pwmAConf or pwmBConf

Definition at line 29 of file Epwm.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated on Sat Apr 16 11:42:44 2011 for TIMotorLIB by  doxygen 1.6.3