DT instant interrupts with mister_e keypad


+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2008
    Posts
    21

    Default DT instant interrupts with mister_e keypad [RESOLVED]

    DT instant interrupts with mister_e keypad (16F628A)

    I'm new to interrupts and tried DT instant interrupts by Darrel Taylor (thanks Darrel). The blinky works great with the INT_INT.

    I want for my program to sleep until woken up by the keypad then go to keypad rutine and flash led as many times as the number pressed.

    So I connected keypad's columns to PortB and tried to invoke RBC_INT. Spent few hours double checking everything. No luck.

    I had the RBC_INT working with a switch on PortB.6 before and that part worked. Sometimes it will work after I cycle the power but on the first press only (press 5, flashes 5 times), after that it won't till I shut power off again. Sometimes it won't flash the led at all. So when it works, the keypad works as well

    Schematic attached.
    Code:
    CMCON  = 7                          ' Set portA to i/o
    DEFINE   OSC  20
    
    TRISA = %00000
    TRISB = %01110000
    
    INCLUDE "DT_INTS-14.bas"            ; Base Interrupt System
    INCLUDE "ReEnterPBP.bas"            ; Include if using PBP interrupts
    include "modedefs.bas"
    include "keypad.bas"
    
    '=======================================================
    ' SCAN_ONCE is set to 1 as well as proper keypad settings inside the keypad.bas
    '=======================================================
    
    LED_Grn     var  PortA.1            
    ctr         var byte
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    RBC_INT,  _Scan,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    @   INT_ENABLE   RBC_INT     ; enable external (INT) interrupts
    
    Main:
    @ sleep
    goto Main
    
    '---[INT - interrupt handler]---------------------------------------------------
    Scan:
      gosub KeypadScan
    
      for ctr = 1 to key
        high led_grn
        pause 200
        low led_grn
        pause 200
      next ctr
    @ INT_RETURN
    
    end
    As always any help appreciated,
    Tom
    Attached Images Attached Images  
    Last edited by Tomexx; - 26th November 2008 at 21:24.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    mister-e's keypad program wasn't written to use RBC interrupts.
    He doesn't leave the pins in the right state after scanning. Only 1 row is left active, and the rest won't trigger an interrupt.

    I think I overcame it awhile back, but I can't find the program at the moment.

    Essentialy, after doing a scan, it just sets all keypad outputs low (RB0-3).
    But it only left the one row active when a key was pressed.

    Wish I could find it.
    <br>
    DT

  3. #3
    Join Date
    Oct 2008
    Posts
    21

    Default

    Oh no.
    I was hoping to use that in my gate opener and run it from a battery, that's why I need the pic to sleep for 99.9% of the time.

    In case you do find your version, please let me know. Till then I guess I'll have to forget about the battery and continually scan the keypad instead of interrupts...

    Is there any other way to do it with interrupts and have pic sleeping in the main loop? Maybe another keypad rutine or something?

    Thanks Darrel
    Tom

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Woohoo! Found it.

    http://www.picbasic.co.uk/forum/show...57&postcount=9

    The Rows and Columns may be different than yours. ?

    The "fix" was
    Code:
    KeypadINT:    
        @ READKEYPAD _ByteA                          ; Get the keypress
        TRISB=%11110000                              ; Reset I/O's
        PORTB=0                                      ; Set all columns LOW
    But now it sounds like that whole program is what you want. (With some sleep time added)
    Combination Gate Opener.

    Check the rest of the thread. It developed further.
    DT

  5. #5
    Join Date
    Oct 2008
    Posts
    21

    Default

    Works!!!

    Quick question, why are you enabling the interrupts after the ASM-ENDASM not inside?

    Code:
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    RBC_INT,  _Scan,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    @   INT_ENABLE   RBC_INT     ; enable external (INT) interrupts
    Why not this?
    Code:
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    RBC_INT,  _Scan,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
        INT_ENABLE   RBC_INT     ; enable external (INT) interrupts
    ENDASM

    Also, why the funny indentation inside ASM-ENDASM? Remember, I'm new to interrupts and don't know assmebler
    Thank you Darrel,
    Tom
    Last edited by Tomexx; - 26th November 2008 at 19:55.

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Quote Originally Posted by Tomexx View Post
    Quick question, why are you enabling the interrupts after the ASM-ENDASM not inside?
    Either way will work fine. But ...
    Different types of interrupts, like Timers or CCP Capture, need to have things set-up before the interrupt is enabled. I just put it that way to show that you don't have to enable it inside that same ASM block. It can be done later in the program too (if needed).

    Also, why the funny indentation inside ASM-ENDASM? Remember, I'm new to interrupts and don't know assmebler
    The INT_LIST macro, or anything else that creates a label, must start in column 1.
    The rest is arbitrary and cannot start in column 1.

    It might look strange because I tried to line up the commas with the comment above the line just as a reminder of what the INT_Handler parameters are.
    Guess it didn't work so good.
    <br>
    DT

Similar Threads

  1. V 2.60 and DT Instant Interrupts?
    By jderson in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 22nd July 2009, 06:48
  2. DT Instant Interrupts help
    By perides in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 26th November 2008, 19:41
  3. 12F683 and DT Instant Interrupts
    By jderson in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 22nd November 2008, 13:47
  4. Keypad and DT's Instant Interrupts
    By Homerclese in forum General
    Replies: 11
    Last Post: - 27th April 2007, 06:32
  5. Replies: 1
    Last Post: - 1st November 2006, 04:11

Members who have read this thread : 3

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