Tool/software: Code Composer Studio
Hi,
I am trying to toggle the GPIO output only at the positive-going zero-cross. "Zero cross detection logic Hardware" of the TMS320F28379D (See the attached figure for the reference) gives an interrupt for both positive as well as negative-going zero crosses.
In order to detect the positive crossing, I have written the following logic inside the adca_ppb_isr function. However, GPIO is getting toggled at both positive and sometimes at negative zero crossings.
//***********************************************************************************************
interrupt void adca_ppb_isr(void)
{
if(AdcaRegs.ADCEVTSTAT.bit.PPB1ZERO)
{
if(((signed int)AdcaResultRegs.ADCPPB1RESULT.all)>0)
{
GpioDataRegs.GPBTOGGLE.bit.GPIO52=1; //pin number 107
}
//
//clear the trip flag and continue
//
AdcaRegs.ADCEVTCLR.bit.PPB1ZERO = 1;
}
PieCtrlRegs.PIEACK.all = PIEACK_GROUP10;
}
//***********************************************************************************************
Can anyone help me to implement the only positive zero crossing using this "Zero cross detection logic Hardware". Thanks in advance.
Regards