Part Number: TMS320F280025C
I developed a code in which ePWM SOC is set to trigger ADC at a constant rate. ADC generates an interrupt upon conversion of the signal, and that interrupt is associated with an interrupt service routine (ISR) in which all the control calculations and PWM updates are performed. Actually, the problem is related with regulating the output voltage of DC-DC converter; output voltage is sensed through on chip ADC and PWM updates are performed through a PI controller in the feedback loop.
The issue is that noise level in the feedback signal is quite large hence ADC readings are not stable. In my control algorithm ADC generates an interrupt after each sample and control calculations are performed. But I want to average out certain number of ADC samples to remove the noise and then perform control action. One solution I came up with is to put a counter in the ISR and add ADC readings in the previous value and then find average after certain number of samples let's say 100.
Is there a more efficient way of doing this, i.e., read n ADC samples and then perform control action. In other words, what is the more efficient way of setting the sampling frequency of ADC and control loop frequency independently?