This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C28x ePWM phase register shadowing

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?

  • Hi Tony,

    My 1st thought at solving this problem is to avoid using software for the phase register loads. Instead I would use the "Digital Compare Event Synchronization Pulse". I know that is a long title, but it is well described in the reference guide for the device your are using.

    Which device are you using?

    For 2837xD is is in section 14.4.3 (literature # spruhm8), for the 2806x it is in section 3.2.2.3.3 (literature #spruh18).

    Keeping the signal in hardware avoids real-time issues that can come from ISRs. You can generate the sync pulse form another counter and configure it for whatever rate you need.

    Hope that helps,
    Jeff
  • Hi Jeff

    I'm using the 28234. The phase being controlled is the relative phase between 2 pwm signal sets so I use the synchronisation already to get the pairs synchronised and then shift the phase between the pairs.

    As far as I understand your suggestion it would be for controlling the phase of a single PWM channel and not relative phase between channels.

    I have found a solution for the interrupt load method. When disabling the interrupt, also set the INTPRD value to 0, and then when enabling the interrupt set the INTPRD to the desired value. This disables the counter while it is not needed.

    Tony
  • Great you have a solution Tony, let us know if have any other issues.