Question: i was trying to debug this code on code composer studio to view my signal on oscilloscope but the code does not debug past the
i was trying to debug this code on code composer studio to view my signal on oscilloscope but the code does not debug past the int main void line. how do i fix this? here is the code:
pwmc
Created on: May
Author: QD
#include FxProject.h
#include Include math.h for sinf and MPI
#include FxDepwm.h
#include FxDpievect.h
#include FxDgpio.h
#define PWMPERIOD For kHz carrier frequency with MHz SYSCLK
#define SINETABLESIZE
#define PHASESHIFT SINETABLESIZE degrees phase shift
#define SINEUPDATEINTERVAL microseconds for Hz fundamental frequency
Sine wave lookup table
float sinetableSINETABLESIZE;
Function prototypes
void InitEPwm;
void InitEPwm;
void InitEPwm;
void InitSineTable;
int mainvoid
InitSysCtrl; Initialize system control
DINT; Disable CPU interrupts
InitPieCtrl; Initialize the PIE control registers
IER x; Disable CPU interrupts and clear all CPU interrupt flags
IFR x; Clear all CPU interrupt flags
InitPieVectTable; Initialize the PIE vector table
InitGpio; Initialize GPIO for ePWM
InitSineTable; Initialize the sine table
InitEPwm; Initialize ePWM
InitEPwm; Initialize ePWM
InitEPwm; Initialize ePWM
while
int i;
fori ; i SINETABLESIZE; i
Update ePWM
EPwmRegs.CMPA.bit.CMPA PWMPERIOD sinetablei;
Update ePWMphaseshifted by degrees
int idxi PHASESHIFT SINETABLESIZE;
EPwmRegs.CMPA.bit.CMPA PWMPERIOD sinetableidx;
Update ePWMphaseshifted by degrees
int idxi PHASESHIFT SINETABLESIZE;
EPwmRegs.CMPA.bit.CMPA PWMPERIOD sinetableidx;
DELAYUSSINEUPDATEINTERVAL; Delay to achieve the Hz fundamental frequency
void InitEPwm
EALLOW;
Set up ePWM
EPwmRegs.TBPRD PWMPERIOD ; Set the PWM period
EPwmRegs.TBPHSall x; Phase is
EPwmRegs.TBCTR x; Clear counter
Set up compare values
EPwmRegs.CMPA.bit.CMPA ; Set the initial compare A value
Set up the counter mode
EPwmRegs.TBCTLbit.CTRMODE TBCOUNTUPDOWN; Count up and down
EPwmRegs.TBCTLbit.PHSEN TBDISABLE; Disable phase loading
EPwmRegs.TBCTLbit.HSPCLKDIV TBDIV; Clock ratio to SYSCLKOUT
EPwmRegs.TBCTLbit.CLKDIV TBDIV;
Set up the action qualifier
EPwmRegs.AQCTLA.bit.CAU AQSET; Set PWMA on event A up count
EPwmRegs.AQCTLA.bit.CAD AQCLEAR; Clear PWMA on event A down count
EDIS;
void InitEPwm
EALLOW;
Set up ePWM
EPwmRegs.TBPRD PWMPERIOD ; Set the PWM period
EPwmRegs.TBPHSall PWMPERIOD ; Phase shift for degrees
EPwmRegs.TBCTR x; Clear counter
Set up compare values
EPwmRegs.CMPA.bit.CMPA ; Set the initial compare A value
Set up the counter mode
EPwmRegs.TBCTLbit.CTRMODE TBCOUNTUPDOWN; Count up and down
EPwmRegs.TBCTLbit.PHSEN TBENABLE; Enable phase loading
EPwmRegs.TBCTLbit.SYNCOSEL TBSYNCIN; Synchronize with ePWM
EPwmRegs.TBCTLbit.HSPCLKDIV TBDIV; Clock ratio to SYSCLKOUT
EPwmRegs.TBCTLbit.CLKDIV TBDIV;
Set up the action qualifier
EPwmRegs.AQCTLA.bit.CAU AQSET; Set PWMA on event A up count
EPwmRegs.AQCTLA.bit.CAD AQCLEAR; Clear PWMA on event A down count
EDIS;
void InitEPwm
EALLOW;
Set up ePWM
EPwmRegs.TBPRD PWMPERIOD ; Set the PWM period
EPwmRegs.TBPHSall PWMPERIOD; Phase shift for degrees
EPwmRegs.TBCTR x; Clear counter
Set up compare values
EPwmRegs.CMPA.bit.CMPA ; Set the initial compare A value
Set up the counter mode
EPwmRegs.TBCTLbit.CTRMODE TBCOUNTUPDOWN; Count up and down
EPwmRegs.TBCTLbit.PHSEN TBENABLE; Enable phase loading
EPwmRegs.TBCTLbit.SYNCOSEL TBSYNCIN; Synchronize with ePWM
EPwmRegs.TBCTLbit.HSPCLKDIV TBDIV; Clock ratio to SYSCLKOUT
EPwmRegs.TBCTLbit.CLKDIV TBDIV;
Set up the action qualifier
EPwmRegs.AQCTLA.bit.CAU AQSET; Set PWMA on event A up count
EPwmRegs.AQCTLA.bit.CAD AQCLEAR; Clear PWMA on event A down count
EDIS;
void InitSineTable
int i;
fori ; i SINETABLESIZE; i
sinetablei sinf MPI i SINETABLESIZE;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
