Hi there,
I am using the DSP 28377D, and in my software I have one PWM interrupt (occurring when TBCTR = 0). When the interrupt occurs I need to read a the ADC value. I wanted to do use the software triggered ADC, but I am not sure if I am using it correctly. The relevant sections of my code are below:
ADC (channel A0) settings:
void SetupADC_A(Uint16 channel)
{
Uint16 acqps;
//determine minimum acquisition window (in SYSCLKS) based on resolution (SYSCLK = 200MHz)
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION){
acqps = 19; //75ns ((14+1)*(1/200MHz) ) 14 is the default value
}
else { //resolution is 16-bit
acqps = 63; //320ns ((63+1)*(1/200MHz))
}
//Select the channels to convert and end of conversion flag
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0;
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is 100 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 0; //forced trigger by software
}
now, when the main software reaches the pwm interrupt:
interrupt void epwm6_isr(void) {
AdcaRegs.ADCSOCFRC1.bit.SOC2 = 1; // Software forced start of conversion in ADC A0 (input current)
i_read = (-0.004346)*((double)(AdcaResultRegs.ADCRESULT2)) + 8.217;
EPwm6Regs.ETCLR.bit.INT = 1; // clear EPWM6 INT flag
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}
In the pwm interrupt I would like to read the ADC content and scale the result to update the value of the current "i_read" as highlighted in the code.
Is there anything else needed to make sure that I get the correct result from the ADC?
Thank you very much for your answer.
Leo