There is no hardware support for interrupts on PORTA. But that doesn't mean you can't use interrupts to do what you want.
A good way is to determine the shortest switch closure that you must detect (50mSec?). Then set up a timer that interrupts
at that rate. You mention that you are already using DT-INTs for timing, if you are using a timer for that, just "piggyback" on
that INT. If you aren't, just set up another timer (I like TMR3 for such things). The interrupt rate must be as fast as the shortest
switch closure you want to be able to detect. You ISR could be something like -
; You can clear the flags as appropriate such that you don't perform multiple operations with one switch push.Code:SwitchInt: ; The ISR IF PORTA.5 = 0 THEN IF SwitchHasBeenClosed = 0 then Pause 10; Debounce IF PORTA.5 = 0 then ; Still low? SwitchHasBeenClosed = 1 SwitchHasBeenClosedFlag = 1 ENDIF ENDIF ELSE IF SwitchHasBeenClosedFlag = 1 then Pause 10 ; Debounce time IF PORTA.5 = 1 then ; Still high? SwitchHasBeenClosedFlag = 0 SwitchHasBeenClosedThenOpened = 1 ENDIF ENDIF ENDIF @ INT_RETURN




Bookmarks