Yes, the C code only need call set_pwm_duty() function.
The problem is that I use L298 to control my motor. It's no problem with ASM but I'm trying in C.
As I want to change the direction I use:
set_pwm2_duty(0); // CCP2 = 0
set_pwm1_duty (duty);// CCP1 = duty
then change
set_pwm1_duty(0);
set_pwm2_duty(duty);
In ASM as we stop CCP2, that is CCP2 = LOW, we just clear CCPR2L.
and we wait to next period to set CCP1. No bang here. Because if CCP1 and CCP2 are both HIGH at a time, bang bang bang boom boom boom
)
So I'm afraid if we need to wait for it or not? as updating value for CCPRxL will it change immediately or wait until the next period???