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.
If I have to do this
EPwm2Regs.CMPA.half.CMPA = (Uint16)(myValue * myValue2 / myValue 3); EPwm2Regs.CMPB = (Uint16)(myValue * myValue2 / myValue 3);
Is it ok to do this instead?
EPwm2Regs.CMPA.half.CMPA = (Uint16)(myValue * myValue2 / myValue 3); EPwm2Regs.CMPB = EPwm2Regs.CMPA.half.CMPA;
A and B are in shadow load mode. Will CMPB have the right value? Or will it have CMPA's old value?
Fulano de Tal,
Yes, the second option is alright. The compiler will generate assembly code that accomplishes line 1 and then accomplishes line 2. You can generally verify this by looking at the generated assembly code.
There is one gotcha that should be known though (and it can hit you in either case). You should run timing analysis to make sure that the shadow load point won't fall between your CMPA and CMPB write. If it can, CMPA can be updated as the active value while CMPB waits until the next PWM cycle (assuming that this is a problem).
Thank you,
Brett