This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PWM generation using TMS320F2812



I want to generate 6 independent PWM pulses with 6 complementary pulses(a total of 12 PWM pulses). This is the code i use, I can't get any output. Please help me.

/*
* main.c
*/
#include "DSP281x_Device.h"
#include "IQmathLib.h"
#include "math.h"
_iq30 sine_table[1000] = {*i have a thousand point sine table here };
void init_system(void);
void init_eva(void);
void init_evb(void);
void pwm_1(void);
void main()
{
init_system();
EALLOW;
GpioMuxRegs.GPAMUX.all = 0x00FF;
GpioMuxRegs.GPBMUX.all = 0x00FF;
GpioMuxRegs.GPADIR.all = 0x00FF;
GpioMuxRegs.GPBDIR.all = 0x00FF;
EDIS;
init_eva();
init_evb();
pwm_1();
for(;;);
}

void init_system()
{
EALLOW;
SysCtrlRegs.WDCR= 0x0068;
// Setup the watchdog
// 0x0068 to disable the Watchdog , Prescaler = 1
SysCtrlRegs.HISPCP.all = 0x1;
// Setup Highspeed Clock Prescaler to divide by 2
SysCtrlRegs.PCLKCR.bit.EVAENCLK=1;
SysCtrlRegs.PCLKCR.bit.EVBENCLK=1;
SysCtrlRegs.PCLKCR.bit.SCIAENCLK=0;
SysCtrlRegs.PCLKCR.bit.SCIBENCLK=0;
SysCtrlRegs.PCLKCR.bit.MCBSPENCLK=0;
SysCtrlRegs.PCLKCR.bit.SPIENCLK=0;
SysCtrlRegs.PCLKCR.bit.ECANENCLK=0;
SysCtrlRegs.PCLKCR.bit.ADCENCLK=0;
// Setup Clock for other Peripherals
EDIS;
}
void init_eva()
{
// EVA Configure T1PWM, T2PWM, PWM1-PWM6
// Initalize the timers
// Initalize EVA Timer1
EvaRegs.T1PR = 0x3A98; // Timer1 period
EvaRegs.T1CMPR = 0x0000; // Timer1 compare
EvaRegs.T1CNT = 0x0000; // Timer1 counter
// TMODE = continuous up/down
// Timer enable
// Timer compare enable
EvaRegs.T1CON.all = 0x8842;
// Initalize EVA Timer2
EvaRegs.T2PR = 0x3A98; // Timer2 period
EvaRegs.T2CMPR = 0x0000; // Timer2 compare
EvaRegs.T2CNT = 0x0000; // Timer2 counter
// TMODE = continuous up/down
// Timer enable
// Timer compare enable
EvaRegs.T2CON.all = 0x8842;
// Setup T1PWM and T2PWM
// Drive T1/T2 PWM by compare logic
EvaRegs.GPTCONA.bit.TCMPOE = 1;
// Polarity of GP Timer 1 Compare = Active low
EvaRegs.GPTCONA.bit.T1PIN = 1;
// Polarity of GP Timer 2 Compare = Active high
EvaRegs.GPTCONA.bit.T2PIN = 2;
// Enable compare for PWM1-PWM6
EvaRegs.CMPR1 = 0x0000;
EvaRegs.CMPR2 = 0x0000;
EvaRegs.CMPR3 = 0x0000;

// Compare action control. Action that takes place
// on a cmpare event
// output pin 1 CMPR1 - active high
// output pin 2 CMPR1 - active low
// output pin 3 CMPR2 - active high
// output pin 4 CMPR2 - active low
// output pin 5 CMPR3 - active high
// output pin 6 CMPR3 - active low
EvaRegs.ACTRA.all = 0x0666;
EvaRegs.DBTCONA.all = 0x04F4; // Enable deadband
EvaRegs.COMCONA.all = 0xA6E0;
}
void init_evb()
{
// EVB Configure T3PWM, T4PWM and PWM7-PWM12
// Step 1 - Initialize the Timers
// Initialize EVB Timer3
// Timer3 controls T3PWM and PWM7-12
EvbRegs.T3PR = 0xFFFF; // Timer3 period
EvbRegs.T3CMPR = 0x0000; // Timer3 compare
EvbRegs.T3CNT = 0x0000; // Timer3 counter
// TMODE = continuous up/down
// Timer enable
// Timer compare enable
EvbRegs.T3CON.all = 0x8842;
// Initialize EVB Timer4
// Timer4 controls T4PWM
EvbRegs.T4PR = 0x0FFF; // Timer4 period
EvbRegs.T4CMPR = 0x0000; // Timer4 compare
EvbRegs.T4CNT = 0x0000; // Timer4 counter
// TMODE = continuous up/down
// Timer enable
// Timer compare enable
EvbRegs.T4CON.all = 0x8842;
// Setup T3PWM and T4PWM
// Drive T3/T4 PWM by compare logic
EvbRegs.GPTCONB.bit.TCMPOE = 1;
// Polarity of GP Timer 3 Compare = Active low
EvbRegs.GPTCONB.bit.T3PIN = 1;
// Polarity of GP Timer 4 Compare = Active high
EvbRegs.GPTCONB.bit.T4PIN = 2;
// Enable compare for PWM7-PWM12
EvbRegs.CMPR4 = 0x0000;
EvbRegs.CMPR5 = 0x0000;
EvbRegs.CMPR6 = 0x0000;
// Compare action control. Action that takes place
// on a cmpare event
// output pin 1 CMPR4 - active high
// output pin 2 CMPR4 - active low
// output pin 3 CMPR5 - active high
// output pin 4 CMPR5 - active low
// output pin 5 CMPR6 - active high
// output pin 6 CMPR6 - active low
EvbRegs.ACTRB.all = 0x0666;
EvbRegs.DBTCONB.all = 0x04F4; // Enable deadband
EvbRegs.COMCONB.all = 0xA600;
}

void pwm_1(void)
{
static int i,j,k,l,m,n = 0;
for(i=0,j=3,k=6,l=5,m=8,n=11;(i<=1000)&&(j<=1000)&&(k<=1000)&&(l<=1000)&&(m<=1000)&&(n<=1000);i+=10,j+=10,k+=10,l+=10,m+=10,n+=10)
{
EvaRegs.CMPR1 = EvaRegs.T1PR-_IQsat(_IQ30mpy(sine_table[i]*_IQ30(0.8),EvaRegs.T1PR/2),EvaRegs.T1PR,0);
EvaRegs.CMPR2 = EvaRegs.T1PR-_IQsat(_IQ30mpy(sine_table[j]*_IQ30(0.8),EvaRegs.T1PR/2),EvaRegs.T1PR,0);
EvaRegs.CMPR3 = EvaRegs.T1PR-_IQsat(_IQ30mpy(sine_table[k]*_IQ30(0.8),EvaRegs.T1PR/2),EvaRegs.T1PR,0);
EvbRegs.CMPR4 = EvbRegs.T3PR-_IQsat(_IQ30mpy(sine_table[l]*_IQ30(0.8),EvbRegs.T3PR/2),EvbRegs.T3PR,0);
EvbRegs.CMPR5 = EvbRegs.T3PR-_IQsat(_IQ30mpy(sine_table[m]*_IQ30(0.8),EvbRegs.T3PR/2),EvbRegs.T3PR,0);
EvbRegs.CMPR6 = EvbRegs.T3PR-_IQsat(_IQ30mpy(sine_table[n]*_IQ30(0.8),EvbRegs.T3PR/2),EvbRegs.T3PR,0);
}
}

what am i doing wrong?