raitl
New Member
This is the part of my code that deals with the IR obstacle detection:
And the problem is, that it won't toggle PWM. If I add call PWM_Enable before the loop: section, then it works but in that case PWM is always enabled which I do not want... I'd appreciate it if you could point me where the problem might be.
Code:
loop:
call IR_test
call go_forward
goto loop
;*******My subroutines*******
PWM_Enable:
bsf CCP1CON, 3
bsf CCP1CON, 2
return
PWM_Disable:
bcf CCP1CON, 3
bcf CCP1CON, 2
return
IR_test:
call PWM_Enable
btfss PORTA,0
goto IR_obstacle
call PWM_Disable
return
IR_obstacle:
call PWM_Disable
STEPS .10
goto Turn_right
return
And the problem is, that it won't toggle PWM. If I add call PWM_Enable before the loop: section, then it works but in that case PWM is always enabled which I do not want... I'd appreciate it if you could point me where the problem might be.