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.

PWM affected by interrupts



I am using PWM to control a motor. I was expecting that PWM would be independent of the CPU core but to my surprise it does not seem to be the case. If I have PWM and an interrupt occurs (due to my encoder) there is an immediate drop in RPM. So if I move the encoder away such that it cannot detect the movement, the motor rotates as expected but as soon as I move the encoder near the motor and it starts sending out interrupts, immediately the motor drops RPM.

Am I doing something wrong or expecting something wrong.? I expect PWM to be independent of the the MCU and certainly not affected by any interrupt processing which can obviously always be expected in any application. 

I am using MSP420F5324 at full 25Mhz

  • Mohammed Lokhandwala said:
    Am I doing something wrong or expecting something wrong.?

    If you are doing PWM in software, then of course encoder interrupt routine will consume CPU cycles off your PWM code thus slowing it down. In case you are using hardware PWM using timer peripheral then there's no way for CPU to somehow slow down hardware timer without changing it's registers or clock settings. So if you tell more like show your code, then possibly we can give you better answers.

**Attention** This is a public forum