#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 | InitPWMSide (ePWMenum PWM, sideEnum side, PWMMODULATION modulation, SWITCHLOGIC switchLogic) |
void | InitSinglePWMOutput (void(*interruptFCN)(void), ePWMenum PWM, sideEnum side, Uint16 tpwm_us, PHSEN phSen, PWMMODE pwmMode, SYNCOSEL syncMode, PWMCARRIER pwmCarrier, PWMMODULATION modulation, INTSEL intSel, SWITCHLOGIC switchLogic) |
void | InitComplementaryPWMOutput (void(*interruptFCN)(void), ePWMenum PWM, Uint16 tpwm_us, Uint16 db_us, PHSEN phSen, 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, SOCTrigger trigger, 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 [] |
void AddEventTrigger | ( | volatile struct EPWM_REGS * | pwmPtr, | |
ePWMSOC | soc, | |||
SOCTrigger | trigger | |||
) |
Selects where the Start of Conversion (SOC) signal is generated
pwmPtr,: | Pointer to EPWM_REGS register for the configuration | |
soc,: | Which sequencer is triggered (SOCNULL/SOCA/SOCB) | |
trigger,: |
|
static void CalculatePrescalerBits | ( | Uint16 | tpwm_us, | |
Uint16 * | hspClkDiv, | |||
Uint16 * | clkDiv | |||
) | [inline, static] |
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
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 reachs 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) |
void Init3phPWM | ( | void(*)(void) | interruptFCN, | |
EPWMX | epwmX, | |||
Uint16 | tpwm_us, | |||
Uint16 | db_us, | |||
PWMCARRIER | pwmCarrier, | |||
PWMMODULATION | modulation, | |||
INTSEL | intSel, | |||
_iq | vBus, | |||
ePWMSOC | soc, | |||
SOCTrigger | trigger, | |||
SWITCHLOGIC | switchLogic | |||
) |
Intializes a set of EPWM outputs to drive a three phase inverter
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 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. | |
vBus,: | DC bus voltage in V ( |
soc,: | SOCNULL/SOCA/SOCB. Generates a start of converion trigger for none, A or B sequencer respectively | |
trigger,: | trigger of SOC. See AddEventTrigger function. | |
switchLogic,: | POS_LOGIC/NEG_LOGIC. Select logic for the switches |
void InitComplementaryPWMOutput | ( | void(*)(void) | interruptFCN, | |
ePWMenum | PWM, | |||
Uint16 | tpwm_us, | |||
Uint16 | db_us, | |||
PHSEN | phSen, | |||
PWMMODE | pwmMode, | |||
PWMCARRIER | pwmCarrier, | |||
PWMMODULATION | modulation, | |||
INTSEL | intSel, | |||
SWITCHLOGIC | switchLogic | |||
) |
Intializes a given EPWM pair in complementary mode
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 | |
phSen,: | select device as master or slave (MASTERPWM/SLAVEPWM) | |
pwmMode,: | normal mode (16 bits) or high resolution ( |
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 |
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:
PWM | is the pwm input to be used |
void InitPWMAPeripheralClocks | ( | void | ) |
void InitPWMBPeripheralClocks | ( | void | ) |
void InitPWMPeripheralClocks | ( | void | ) |
void InitPWMSide | ( | ePWMenum | PWM, | |
sideEnum | side, | |||
PWMMODULATION | modulation, | |||
SWITCHLOGIC | switchLogic | |||
) |
Intializes a given EPWM side (A/B). This function only can be called after one output for the given EPWM module has been configured. Example: InitSinglePWMOutput(pwmInterrupt, PWM1, xA, TPWMA_US, MASTERPWM, SYNC_DISABLE, NORMAL_MODE, TRIANGLE, SYMMETRICAL, CTR_ZERO, POS_LOGIC); InitPWMSide(PWM1, xB, SYMMETRICAL, POS_LOGIC);
PWM,: | Selection of PWM input to be configured (PWM1...PWM6) | |
sideEnum,: | Selection of A/B switches | |
modulation,: | SYMMETRICAL/ASYMMETRICAL. If symmetrical, comparison | |
switchLogic,: | POS_LOGIC/NEG_LOGIC. Select logic for the drived switch |
void InitSinglePWMOutput | ( | void(*)(void) | interruptFCN, | |
ePWMenum | PWM, | |||
sideEnum | side, | |||
Uint16 | tpwm_us, | |||
PHSEN | phSen, | |||
PWMMODE | pwmMode, | |||
SYNCOSEL | syncMode, | |||
PWMCARRIER | pwmCarrier, | |||
PWMMODULATION | modulation, | |||
INTSEL | intSel, | |||
SWITCHLOGIC | switchLogic | |||
) |
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:
const Uint16 _offsetPWM |
volatile Uint16* cmpPtr[PWM_OUTPUTS_SIZE] |
struct EPWM_REGS* ePWM[] |
const Uint16 hspClkIndxMat[] [static] |
const Uint16 lspClkIndxMat[] [static] |
int MEP_ScaleFactor[PWM_CH] = {0,0,0,0,0} |
struct PWM3phConfiguration pwmAConf |
struct PWM3phConfiguration pwmBConf |
struct PWM3phConfiguration pwmConf |