Interrupts are the best way, but if you can't use those you can do it as follows:
TopOfLoop:
If Old.Y ^ PortX.Y > 0 THEN
Old.Y = PortX.Y
IF PortX.Y = 1 THEN GOTO DoSomething
ENDIF
GOTO TopOfLoop
DoSomething:
The program loops and tests the port bit against a saved value using
the bitwise exclusive OR. If the saved value is different, then "Old"
is set equal to the port bit. Only when the Port bit has switched from
"0" to "1" will it jump out of the loop.
Bookmarks