Part Number: TMS320F28377S
Hello,
I am trying to use DCCAP to calculate when an ADC value crosses a threshold. I get the first time stamp, but the clear doesn't seem to have an effect. I'm able to manually clear in the watch window and values update, but it then remains the same. My understanding, per a previous thread, was the clear bit would allow me to capture on every event.
Previously, I had the clear in each separate if statement and moved it out for debug purposes. With the CAPCLR outside the if statements, I still do not see my status bit clearing.
My code is as follows:
if(AdcbResultRegs.ADCRESULT5 > THRESHOLD && rise1Captured == 0)
{
EPwm4Regs.AQCTLA.bit.ZRO = AQ_SET;
Time1 = (float32)(EPwm4Regs.DCCAP);
rise1Captured = 1;
EPwm4Regs.AQCTLA.bit.ZRO = AQ_CLEAR;
}
else if(AdcbResultRegs.ADCRESULT5 < THRESHOLD && fallCaptured == 0)
{
EPwm4Regs.AQCTLA.bit.ZRO = AQ_SET;
Time2 = (float32)(EPwm4Regs.DCCAP) + powerTime1;
EPwm4Regs.AQCTLA.bit.ZRO = AQ_CLEAR;
fallCaptured = 1;
}
else if(AdcbResultRegs.ADCRESULT5 > THRESHOLD && fallCaptured == 1)
{
EPwm4Regs.AQCTLA.bit.ZRO = AQ_SET;
Time3 = (float32)(EPwm4Regs.DCCAP) + powerTime2;
EPwm4Regs.AQCTLA.bit.ZRO = AQ_CLEAR;
rise1Captured = 0;
fallCaptured = 0;
}
EPwm4Regs.DCCAPCTL.bit.CAPCLR = 1;
Any insight is appreciated.
Thanks,
Cameron