I am trying to use the library files from DMC to generate PWM signals from F2812 DSP. However, there is no PWM output at all. I checked the registers but still no clues. Here is file I used
/* ==================================================================================
File name: F281XPWM.C
Originator: Digital Control Systems Group
Texas Instruments
Description: This file contains source for the Full Compare PWM drivers for the F281x
Target: TMS320F281x family
=====================================================================================
History:
-------------------------------------------------------------------------------------
04-15-2005 Version 3.20: Using DSP281x v. 1.00 or higher
----------------------------------------------------------------------------------*/
#include "DSP281x_Device.h"
#include "f281xpwm_an.h"
#define ACTR_DISABLE_STATE ( COMPARE1_FL + \
COMPARE2_FL + \
COMPARE3_FL + \
COMPARE4_FL + \
COMPARE5_FL + \
COMPARE6_FL )
void F281X_EV1_PWM_Init(PWMGEN *p)
{
EvaRegs.T1PR = p->PeriodMax; // Init Timer 1 period Register
EvaRegs.T1CON.all = PWM_INIT_STATE; // Symmetrical Operation
EvaRegs.DBTCONA.all = DBTCON_INIT_STATE; // Init DBTCONA Register
// EvaRegs.ACTRA.all = ACTR_INIT_STATE; // Init ACTRA Register
EvaRegs.ACTRA.all = ACTR_DISABLE_STATE;
EvaRegs.COMCONA.all = 0xA200; // Init COMCONA Register
EvaRegs.CMPR1 = p->PeriodMax; // Init CMPR1 Register
EvaRegs.CMPR2 = p->PeriodMax; // Init CMPR2 Register
EvaRegs.CMPR3 = p->PeriodMax; // Init CMPR3 Register
EALLOW; // Enable EALLOW
GpioMuxRegs.GPAMUX.all |= 0x003F; // Setting PWM1-6 as primary output pins
EDIS; // Disable EALLOW
}
void F281X_EV1_PWM_Update(PWMGEN *p)
{
int16 MPeriod;
int32 Tmp;
Uint16 Tmp2;
// Compute the timer period (Q0) from the period modulation input (Q15)
Tmp = (int32)p->PeriodMax*(int32)p->MfuncPeriod; // Q15 = Q0*Q15
MPeriod = (int16)(Tmp>>16) + (int16)(p->PeriodMax>>1); // Q0 = (Q15->Q0)/2 + (Q0/2)
EvaRegs.T1PR = MPeriod;
// Compute the compare 1 (Q0) from the PWM 1&2 duty cycle ratio (Q15)
Tmp = (int32)MPeriod*(int32)p->MfuncC1; // Q15 = Q0*Q15
Tmp2 = (int16)(Tmp>>16) + (int16)(MPeriod>>1); // Q0 = (Q15->Q0)/2 + (Q0/2)
if (p->IaDir >0) {
Tmp2 += p->deadTime;
}else {
if (Tmp2 > p->deadTime) {
Tmp2 -= p->deadTime;
}else {
Tmp2 = 0;
}
}
if (Tmp2 >= MPeriod) {
Tmp2 = MPeriod-1;
}
EvaRegs.CMPR1 = Tmp2;
// Compute the compare 2 (Q0) from the PWM 3&4 duty cycle ratio (Q15)
Tmp = (int32)MPeriod*(int32)p->MfuncC2; // Q15 = Q0*Q15
Tmp2 = (int16)(Tmp>>16) + (int16)(MPeriod>>1); // Q0 = (Q15->Q0)/2 + (Q0/2)
if (p->IbDir >0) {
Tmp2 += p->deadTime;
}else {
if (Tmp2 > p->deadTime) {
Tmp2 -= p->deadTime;
}else {
Tmp2 = 0;
}
}
if (Tmp2 >= MPeriod) {
Tmp2 = MPeriod-1;
}
EvaRegs.CMPR2 = Tmp2;
// Compute the compare 3 (Q0) from the PWM 5&6 duty cycle ratio (Q15)
Tmp = (int32)MPeriod*(int32)p->MfuncC3; // Q15 = Q0*Q15
Tmp2 = (int16)(Tmp>>16) + (int16)(MPeriod>>1); // Q0 = (Q15->Q0)/2 + (Q0/2)
if (p->IcDir >0) {
Tmp2 += p->deadTime;
}else {
if (Tmp2 > p->deadTime) {
Tmp2 -= p->deadTime;
}else {
Tmp2 = 0;
}
}
if (Tmp2 >= MPeriod) {
Tmp2 = MPeriod-1;
}
EvaRegs.CMPR3 = Tmp2;
}