DT's Instant Interrupts trouble


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2008
    Posts
    21

    Default DT's Instant Interrupts trouble

    Hi,
    I'm very new to the interrupts but I came across Darrel Taylor's instant interrupts and wanted to give it a try. So I tried his program to toggle the led with no problems (thanks Darrel). A pushbutton connected to RB0 (INTE) interrupts main loop and a LED toggles.

    Code:
    CMCON = 7                    ' PortA = digital I/O
    LED1   VAR  PORTA.1
    
    INCLUDE "DT_INTS-14.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ; Include if using PBP interrupts
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
        INT_Handler    INT_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    @   INT_ENABLE   INT_INT     ; enable external (INT) interrupts
    
    Main:
    @ sleep
    GOTO Main
    
    '---[INT - interrupt handler]---------------------------------------------------
    ToggleLED1:
      TOGGLE LED1
    @ INT_RETURN
    So now I'm feeling adventurous and wanted to try the interrupts on PortB (RBC_INT). Replaced INT_INT with RBC_INT and moved the switch to B1 but my LED won't toggle anymore when I push the switch (no interrupts)
    Code:
    CMCON = 7                    ' PortA = digital I/O
    LED1   VAR  PORTA.1
    
    INCLUDE "DT_INTS-14.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ; Include if using PBP interrupts
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
        INT_Handler    RBC_INT,  _ToggleLED1,   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]---------------------------------------------------
    ToggleLED1:
      TOGGLE LED1
    @ INT_RETURN
    Am I supposed to do something else for RBC_INT?

    Thanks,
    Tom

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default

    What chip are you using? Many have only on the 4 upper bits of portb the Interrupt on change feature.

    Also check if the option register is set properly or any other register according to the PIC you are using.

    Ioannis

  3. #3
    Join Date
    Oct 2008
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    16F628A. I moved the switch to RB.5, now my led dims but doesn't turn off when push button is pressed.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default

    Put an osciloscope on the LED port and you will see why.

    You keep on toggling the port while pressing the button and that's why you see the LED dimming.

    Other than that your program is OK!

    Ioannis

  5. #5
    Join Date
    Oct 2008
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    It did toggle with my previous setup with switch on B.0 using INT_INT so it should toggle now on B.5 using RBC_INT as well.

    When I press the switch I get 2.2V on the led

    I think the problem is due to some noise on the lines as my led fill go on/off when I touch the wires. Never had it on B.0, the toggling was smoth with no noise and no dimming.

  6. #6
    Join Date
    Oct 2008
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    Works now.
    I changed the RC values of my switch debouncing and changed the interrupt rutine from:
    Code:
    toggle led1
    to
    Code:
    low LED1
    pause 50
    high led1
    pause 50
    Now it works providing I don't hold the switch for too long or it triggers another interrupt.

    Code:
    CMCON = 7                    ' PortA = digital I/O
    
    INCLUDE "DT_INTS-14.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ; Include if using PBP interrupts
    
    LED1   VAR  PORTA.1
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
        INT_Handler    RBC_INT,  _ToggleLED1,   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]---------------------------------------------------
    ToggleLED1:
      low LED1
      pause 50
      high led1
      pause 50
    @ INT_RETURN

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    For interrupt-on-change you need to read the port to allow the interrupt flag bit to be
    cleared. This takes a snap-shot of the port logic, and triggers the interrupt-on-change
    again once the value on the port changes after the last read.

    To prevent it from interrupting if you hold a button down too long, then release it, just
    use a while/wend to wait for the button to be released. I.E. wait until the switch is
    released before exiting your interrupt handler. Then only the change when your switch is
    pressed should generate the interrupt.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8
    Join Date
    Oct 2008
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    Thanks Bruce that did it!
    By the way, your website is very informative.

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 22:14
  2. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  3. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 20:02
  4. DTs instant Interrupts
    By Mugelpower in forum PBP Wish List
    Replies: 5
    Last Post: - 22nd February 2008, 17:26
  5. Keypad and DT's Instant Interrupts
    By Homerclese in forum General
    Replies: 11
    Last Post: - 27th April 2007, 06:32

Members who have read this thread : 2

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