When using the comparator, I am trying to toggle the ePWM1A output; I am aware that the comparator can be initialized to either force ePWM1A high OR low, but not toggle.
The first question is, can ePWM1A output be toggled?
I wrote code which compiles and loads OK without warnings, but which doesn't appear to work.
Generally, I am initializing the peripherals, entering an infinite while loop, and allowing the ePWM to establish the interrupt. Below is the code for my interrupt loop; note that I use "flag" as a state variable. Also, without the if/else statement, the operation of the comparator/ePWM is fine.
Does anyone see anything that I've done wrong? Could it be that initialization takes so much time that it is impractical to change it in an interrupt loop (which has a 10 microsecond sampling rate)?
void isr_int3pie1_task_fcn(void)
{
EALLOW;
if(flag == 0)
{
EPwm1Regs.TZCTL.bit.TZA = 2;
EPwm1Regs.TZCTL.bit.DCAEVT2 = 2;
}
else
{
EPwm1Regs.TZCTL.bit.TZA = 1;
EPwm1Regs.TZCTL.bit.DCAEVT2 = 1;
}
EDIS;
AdcRegs.ADCSOCFRC1.bit.SOC0 = 1;
asm(" RPT #22 || NOP");
ADC0 = (AdcResult.ADCRESULT0);
Comp1Regs.DACVAL.bit.DACVAL = ADC0;
flag = !flag;
}