You can use ON DEBUG to "Poll" every pin on the chip, which acts a lot like ON INTERRUPT.
Between each line of PBP code, it will jump to the debug routine which checks all the pins to see if anything has changed.
This demo program monitors the 16-pins on PORTB and PORTC, and transfers them to PORTD, PORTA and PORTE.
The main loop continues blinking PORTE.2 (green LED) while it "Polls" the pins.
Click image for larger version

Click image for larger version
Code:
DEBUG_ADDRESS var word bank0 system ' Program address
ThisPORTB VAR BYTE
ThisPORTC VAR BYTE
LastPORTB VAR BYTE
LastPORTC VAR BYTE
PauseCount VAR WORD
IOCW VAR WORD
ADCON1 = 7
CMCON = 7
PORTD = 0
TRISD = 0
PORTA = 0
TRISA = 0
PORTE = 0
TRISE = 0
;--------------------------------------------------------------------------------------------
ON DEBUG GOTO Monitor16
Main:
HIGH PORTE.2
GOSUB PAUSE500
LOW PORTE.2
GOSUB PAUSE500
GOTO Main
PAUSE500:
FOR PauseCount = 1 to 500
PAUSEUS 980
NEXT PauseCount
RETURN
DISABLE DEBUG
;--------------------------------------------------------------------------------------------
Monitor16:
ThisPORTB = PORTB
ThisPORTC = PORTC
IF ThisPORTB != LastPORTB THEN
LastPORTB = ThisPORTB
PORTD = ~ThisPORTB
ENDIF
IF ThisPORTC != LastPORTc THEN
LastPORTC = ThisPORTC
PORTA = ~ThisPORTC
PORTE = ~(ThisPORTC >> 6)
ENDIF
exitdebug:
' End of debug routine - go back to main program
asm
movf DEBUG_ADDRESS + 1, W ; Set PCLATH with top byte of return address
movwf PCLATH
movf DEBUG_ADDRESS, W ; Go back to main program
movwf PCL
endasm
Bookmarks