I've had a problem with the analog-to-digital converter (ADC) end-of-conversion (EOC) Interrupt not not vectoring intermittently on the F28027 controlCARD.
My program has an ePWM driving SOC's on the ADC and then some calculations are done and pins toggled during the subsequent EOC ISR. When the problem occurred, the program would run flawlessly for a variable amount of time, sometimes seconds or minutes, before it failed. When it did fail, it did not lock up, as the main loop was still running and the ePWM was still triggering SOC's because the ADC result registers were still updating. The main loop is just a dummy loop that waits for the EOC ISR's to progress the program.
What did go wrong was the AdcRegs.ADCINTFLG.bit.ADCINT1 was being set but it wasn't going to the interrupt routine anymore. This seemed to happen more quickly when the ADC input was of a low frequency below 100 Hz. When it failed, the Pie acknowledge register didn't seem to get set anymore.
I seemed to track it down to one problematic line that when commented, allowed it to keep processing the EOC indefinitely:
EPwm1Regs.CMPA.all = (Uint32) floor( (AverageBuffer(fCircularBuffer) + 100000) * ScaleFactor) << 8;
This line does some calculations on the ADC input data and then changes the HRPWM duty cycle to change the output. I currently have changed this line to multiple lines in the hopes that the very long line might have been confusing the compiler.
tempfloat32 = (AverageBuffer(fCircularBuffer) + 100000) * LockinToDutyCycleRatio;
tempUint32 = (Uint32) tempfloat32 << 8;
EPwm1Regs.CMPA.all = tempUint32;
At the moment, it seems to be working, but this failure has been intermittent at times, so I can't be positive it's fixed. I'd feel more comfortable if I knew:
1. Why it has been failing to do the ADC EOC vectoring? (even when the ADC was still receiving SOC's and updating the result registers)
2. Is there some way I can recover gracefully if this happens again? Like resetting the PIE or ADC somehow?