Part Number: TMS320F28388D
We have some specific timing requirements on when we can start ADC reading. We use the PWM to trigger the ISR and start our ADC. We use the PWM count and verify that we are withing the first 1-2 usec of the count to start the read.
What we are doing is running the PWM at 48 usec timer, however, when told to we sync the PWM to the SYNC0 ISR Pulse on EtherCAT (which runs at 250 usecs). What we see and expect is that on occassion we will have a pending interrupt for the PWM. Since we techinically could get the PWM counter ISR and then a few usecs later get the Sync0 Pusle, which should set the PWM counts back down to zero (by the way is this correct?)
I thought that doing EPWM_clearEventTriggerInterruptFlag would clear the current interrupt and any pending interrupt but doing some reading in the forum it doesn't appear that way. If the PWM has a pending ISR once we do the EPWM_clearEventTriggerInterruptFlag then the pending interrupt will fire and once we leave the interrupt handler we will immediately come back into the Interrupt handler again (baring any other higher interrupts).
Since we know based on timing that we could get 1 interrupt, be processing it and having one pending because the Sync0 pulse came in we are getting back into the ISR handler with the pwm count being to high to start our ADC reads and we throw and error. We know we will get into this situation is there a way to fix this.
What we would like to do is clear the current PWM interrupt and any pending PWM interrupts before leaving the ISR. This way there is nothing pending. Is there a correct way to do this?
Dorion

