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.
Hi, sorry to post this in the technical FAQ, but I couldn't find the button to start a new forum, and the other DSP forums are not for TMS320F2812.
Simply put, I want to use EVB to run a single PWM with an adjustable duty cycle on PWM7. I am using EVA for the ADC ISR.
I started with the example code in Example_281xEvPwm.c and trimmed out the T4 related stuff.
// these globals get set at the beginning of main, before the call to init_evb
Uint16 vout;
Uint16 vinc;
Uint16 period;
Uint16 compare;
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 = period; // Timer3 period
EvbRegs.T3CMPR = compare; // Timer3 compare
EvbRegs.T3CNT = 0x0000; // Timer3 counter
// TMODE = continuous up/down
// Timer enable
// Timer compare enable
EvbRegs.T3CON.all = 0x1042;
EvbRegs.GPTCONB.bit.TCMPOE = 1;
// Polarity of GP Timer 3 Compare = Active low
EvbRegs.GPTCONB.bit.T3PIN = 1;
// Enable compare for PWM7-PWM12
EvbRegs.CMPR4 = 0x0C00;
EvbRegs.ACTRB.all = 0x0002;
EvbRegs.DBTCONB.all = 0x0000; // Disable deadband
EvbRegs.COMCONB.all = 0xA600;
} // init_evb
Then some of my own code:
[ in a function that handles commands from the host pc, I try to adjust the duty cycle...
else if(b0 == '3')// decrease duty cycle to lower voltage
{
vout = vout - vinc;
//EvbRegs.T3CMPR = vout; // Timer3 compare // seems to have no effect
EvbRegs.T3PR = vout; // Timer3 period // causes changes in output but is wrong
}
]
So, what I want is a very simple PWM output with adjustable duty cycle. Everything I've read suggests that if I change T3CMPR, this should happen, but I see absolutely no change in the output. I honestly don't care when in the cycle it's changed, if it's symmetric or anything. I just want to be able to change the duty cycle of the PWM.
Is there a compare enable or something that I need to disable before trying to adjust T3CMPR? I have not seen mention of this in spru065e.pdf (which unfortunately has no example code in it).
Thanks for any help you can provide with this. It seems like it should be the easiest thing to do with a PWM.
Hi, can you help me. I use bit FCMP1OE to put PWM1 in high-impedance state. When in high-impedance state I get high level on output, probably because internal pull-up on this pin. How can I change this output on low level when pin is high-impedance state?