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.

should the PWM compare value be updated inside the PWM interrupt service routine?

Other Parts Discussed in Thread: CONTROLSUITE

Hi there,

I am using a DSP 28377D to control a converter and I just have a question in regards to the "type" of code which is normally executed inside the pwm interrupt service routine (ISR). In my code an interrupt is triggered every time the Time Base Counter equals zero.

In my code there is a PI controller whose output is the duty ratio, which in turn is the CMP value of the PWM, determining the switch-on time.

My question is, do you usually execute the PI controller code inside the PWM ISR? and then you update the the CMP value of the PWM still inside the PWM ISR?

I just wanted to know if there is a best practice regarding where to calculate the control and update the CMP value. It is best to do this in the infinite loop (background loop) or inside the pwm ISR?

Also, if you have any reference to help understand these kind of topics, could you please share it?

Thank you so much,

Leo 

  • Hi Leo,

    It's always preferred to do inside an ISR - so that the timing of the register updates is predictable always.
    Hence, PI execution and CMP reg updates to control the duty cycle are all done inside the ISR.
    Which application are you using the device for?
    There are several examples in controlSuite - the software repository for C2000 devices and applications.
    Please go through the examples and feel free to post any further questions on the forum.

    -bharathi