Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: C2000WARE
Tool/software: Code Composer Studio
Hello, I'm new using the C2000 family of microcontrollers and having troubles to implementing a Single Phase Phase Locked Loop algorithm in my F28379D DSP.
The signal I'm tracking is a sine wave created by EPwm5 varrying it's that Duty Cycle with EPwm5Regs.CMPA.bit.CMPA register. Then I connect the output of the Epwm5A on low-pass filter and read with ADC0 pin the filtered signal and gets this:
Then I have to treat digitally the wave to become a sine wave varrying from 1 to -1. Here starts my doubts.
I created a static float variable to try to reach this signal but it's value keeps on 0. After this I'll need to implement the difference equation using the values of the new variable digitally treated. Below it's the code that I tried to use in the void of the ADC routine.
#define ajuste_tensao 1/1864
#define offset 1800.0
static float seno_entrada;
interrupt void adca1_isr(void){
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT0;
seno_entrada = ((AdcaResults[1])-offset)*ajuste_tensao;
if(RESULTS_BUFFER_SIZE <= resultsIndex)
{
resultsIndex = 0;
bufferFull = 1;
}
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
if (n<6.283){
n=n+ajuste;
sen=0.5*(1+sin(n));
EPwm5Regs.CMPA.bit.CMPA = sen*0x1000;
}
else{
EPwm5Regs.CMPA.bit.CMPA = 0x0000;
n=0;
}
}


