I'm using 8-bit resolution for PWM so it should be a byte but I have the variable defined as WORD in case the math takes it over 255:
Code:
MotorDuty VAR WORD ; Actual duty cycle for motor
ChngMotorHPWM:
CCP3CON.4 = MotorDuty.0
CCP3CON.5 = MotorDuty.1
CCPR3L = MotorDuty >> 2
CCP4CON.4 = MotorDuty.0
CCP4CON.5 = MotorDuty.1
CCPR4L = MotorDuty >> 2
RETURN
Do you think the issue would be resolved if I change the datatype of MotorDuty to BYTE? I was also thinking I might switch to 10-bit resolution for both ADC and PWM to get the finest grain control of the motor speed, but that may be overkill.
Bookmarks