DT Interupts PortA or PortB?


Results 1 to 6 of 6

Threaded View

  1. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: DT Interupts PortA or PortB?

    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 -


    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
    ; You can clear the flags as appropriate such that you don't perform multiple operations with one switch push.
    Last edited by Charles Linquis; - 8th December 2011 at 02:42.
    Charles Linquist

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts