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.

TMS320F28027 experimental kit digital filter

Other Parts Discussed in Thread: TMS320F28027

The following is only part of my code. ADCINA4_Voltage_sum is the input  anlogue to digital converter value of sinusoidal signal generated by signal generator. v0 is a variable of an implemented digital filter which is used to generate phase for a output sinusoidal signal on GPI06.

However oscilloscope shows that there is no output signal in GPI06 after few cycles (50Hz). i believe this problem is becuase digital filter is designed an coded in such way that value of variable v0 keeps increasing to wards infinity. however in this program v0 is a IQ math value _iq15 that cannot be more than definite value(65535.999969482). Thus I can only observe the frist few cycles.

How can I hold an infinitely progressing real time operation in a variable???

while(1)

{
         ADCINA4_Voltage = (ADCINA4_Voltage_sum - 2047);//CENTRED SINE SIGNAL AND SCALE BY 0.95
         ADCINB4_Voltage = (AdcResult.ADCRESULT1-2046)*0.95;
         c1 = EPwm2Regs.TBCTR;
         c2 = (c1 -1000)* 2.047;//triangle carrier centred at zero with amplitude +- 2046
     


                in = _IQ(ADCINA4_Voltage);
                div  =  _IQ(2048);
                realin = _IQ(in/div);//realin = _IQ(in/div);//real part of ADC signal//commented temporarily
                Z = _IQacos(realin);

                imagin = _IQsin(Z);//imag part of input signal



                realout = _IQcos(phiout[i]);//phiout initiallly zero updates at end of while 1 loop
               imagout = _IQsin(phiout[i]);


                v2= _IQ(v1);
                v1= _IQ(v0);
              ph1 = _IQatan2(imagin,realin);
              ph2 = _IQatan2(imagout,realout);


              pherr = _IQ(ph1-ph2);

              v0 = _IQ(pherr + v1*2 - v2*1);

              b0 = _IQ(0.027880390);
              b1 = _IQ(0.000777695);
              b2 = _IQ(-0.027102694);



              phiout = _IQmpy(v0, b0);
              phiout += _IQmpy(v1, b1);
              phiout += _IQmpy(v2, b2);
              scale = _IQ(1900);

             }




              Y =  _IQmpy(realout, scale);


              if(Y >= 0)
              {
                if (Y < c2)
                {
                    GpioDataRegs.GPACLEAR.bit.GPIO6 = 1;
                }

                else
                {
                    GpioDataRegs.GPASET.bit.GPIO6 = 1;
                }
              }


              else if (Y < 0)
              {
           if (abs(Y) < abs(c2))
           {
               GpioDataRegs.GPASET.bit.GPIO6 = 1;
           }

           else
           {
               GpioDataRegs.GPACLEAR.bit.GPIO6 = 1;
           }

              }
     }

}