rocky79
- 24th August 2005, 00:03
Can anyone spot my mistake in this simple program. The program run but it will never go into the wakeup mode. thank you much see below:
' this is for pic12f675
ANSEL=0 ' change pin into digital Input
CMCON=7
pulsewidth var word
counter var word
looptime con 10000
pulsin 4,1,pulsewidth ' read the pulse width at pin 4
for counter=0 to looptime 'loop
if pulsewidth >150 then gosub switch ' read pulse width again
if pulsewidth=0 then gosub blink
pulsin 4,1,pulsewidth
pause 1
if counter=looptime-1 then gosub wakeup
next counter
switch:
low 2 'pin 2 becomes ground =20 ohms resistance w ground
pause 1000
input 2 ' pin 2 becomes open collector means high impedance
pause 1000
counter=0 ' reset the counter
return
' : wake up will do the same thing as the switch function above but only after
' the loop times out
wakeup:
low 2 'pin 2 becomes ground =20 ohms resistance w ground
pause 1000
input 2 ' pin 2 becomes open collector means high impedance
pause 1000
counter=0
return
blink: ' blink the led
high 0
pause 80
low 0
pause 80
counter=0
return
' this is for pic12f675
ANSEL=0 ' change pin into digital Input
CMCON=7
pulsewidth var word
counter var word
looptime con 10000
pulsin 4,1,pulsewidth ' read the pulse width at pin 4
for counter=0 to looptime 'loop
if pulsewidth >150 then gosub switch ' read pulse width again
if pulsewidth=0 then gosub blink
pulsin 4,1,pulsewidth
pause 1
if counter=looptime-1 then gosub wakeup
next counter
switch:
low 2 'pin 2 becomes ground =20 ohms resistance w ground
pause 1000
input 2 ' pin 2 becomes open collector means high impedance
pause 1000
counter=0 ' reset the counter
return
' : wake up will do the same thing as the switch function above but only after
' the loop times out
wakeup:
low 2 'pin 2 becomes ground =20 ohms resistance w ground
pause 1000
input 2 ' pin 2 becomes open collector means high impedance
pause 1000
counter=0
return
blink: ' blink the led
high 0
pause 80
low 0
pause 80
counter=0
return