Rewrite of SW PWM