----------
I did it like this
RESETALL VAR PORTA.0
RSTPLS VAR BIT
HULP0 VAR BIT
RSTPLS = RESETALL & ~ HULP0
HULP0 = RESETALL
(& = logical and ~ = invert)
' At RSTPLS you will get a pulse what is one cycle of your program if RESETALL goes high.
Ofcource
while
RESETALL = 1
wend
will also work
I am not sure exactly what you are trying to do ???
; If you are only looking for 0V-5V (and not 5V-0V) then try this
; example of monitoring RB0, RB2, and RB4 for change
old var byte
main:
pause 10
old = PORTB & %00010101
if old = 0 then main
; do something here because a pin went high
; to find which pin went high
if old.0 = 1 then here4RB0
if old.2 = 1 then here4RB2
if old.4 = 1 then here4RB4
here4RB0:
do something
goto main
here4RB2
do something
goto main
here4RB4
do something
goto main
Another approach - You also could just poll the port directly,
main:
If PORTB.0 = 1 then here4RB0
If PORTB.2 = 1 then here4RB2
If PORTB.4 = 1 then here4RB4
pause 10
goto main
etc
************************************************** ************
; If you are looking for 0V-5V or 5V-0V then try this
; example of monitoring RB0, RB2, and RB4 for change
old var byte
nowHigh var byte
main:
old = PORTB & %00010101
pause 10
newHigh = PORTB & %00010101
if old = newHigh then main ; no change on RB0, RB2, RB4
; do something here because a pin changed
old = old ^ newHigh ; find changed pin(s) (bit or bits will be set for changed pin(s))
if old.0 = 1 then here4RB0
if old.2 = 1 then here4RB2
if old.4 = 1 then here4RB4
here4RB0:
if newHigh.0 = 1 then
do something ; pin when from low to high
else
do something else ; pin went from high to low
endif
goto main
here4RB2
do something
goto main
here4RB4
do something
goto main
Good Luck,
Paul Borgmeier
Salt Lake City, Utah
USA
Bookmarks