My code needs to update the phase based on the output of a controller. If the phase is updated immediately PWM glitches can occur based on missed counter compares. Ideally I would like a shadow register for the phase but as far as I can tell the C28x does not provide this for phase.
Therefore my proposed solution is to trigger an interrupt on counter reload of the PWM and load the phase in the interrupt. However my controller opperates at a lower frequency to the ePWM and don't want to reload the phase value every cycle. Therefore I enable the interrupt when a new phase value is available, and disable the interrupt inside the ISR.
However The INTCNT count value in the ETPS interrupt only stops counting once it hits the prescale value (as far as I can tell according to the reference guide). However also according to the reference guide the counter can only be reset on a interrupt pulse. This means the interrupt first triggers as soon as it is enabled.
Firstly is there an easier way of achieving shadowing effect on the phase register without any busy waits?
Second if this is the best way of achieving my intended result how do I reset the INTCNT value to prevent the interrupt from triggering straight away?