Here is my code for the whole program. Basically it switches two outputs based on the pulse width of two incoming signals.
Code:
' ---------------------------------------------
' Define aliases to the LED ports
' ---------------------------------------------
PWM1 var GPIO.0
PWM2 var GPIO.1
IO1A var GPIO.2
IO1B var GPIO.5
IO2 var GPIO.4
PwmCount1 var byte ' Count number of cycles for PWM1
PwmCount2 var byte ' Count number of cycles for PWM2
INTCON.6=0 ' Disable all unmasked Interrupts
INTCON.7=0 ' Disable Global Interrupts
CMCON = 7
'------------------------------
' Main program starts here
'------------------------------
input PWM1
input pwm2
output IO1A
output IO1B
output IO2
pwmcount1 = 0 ' Initialize PWM counter variables
pwmcount2 = 0
MAIN:
pulsin pwm1,1,PwmCount1
PULSin pwm2,1,PwmCount2
if Pwmcount1 > 140 then
IO1A = 1
IO1B = 1
else
IO1A = 0
IO1B = 0
endif
if Pwmcount2 > 140 then
IO2 = 1
else
IO2 = 0
endif
goto MAIN 'endless loop
END
I will try switching IOA and IOB simultaneously and see if that works.
Thanks,
Jeff
Bookmarks