First try at DT_INT's, I failed! help please!



THE BOOK of DT's INTERRUPTS is an organization of interrupt service routines and other works written by Darrel Taylor, RIP.

Interrupt routines are arranged per Darrel's original list. Darrel Taylor's Instant Interrupts are an extension of the work of Tim Box whom in October of 2002 wrote INT_CTRL.pbp

Many of the forum members felt this is a long overdue project.

THE BOOK of DT's INTERRUPTS
will be a valuable resource and a tribute to Darrel Taylor the "Fanatical Contributor".

THE BOOK of DT's INTERRUPTS is located at http://dt.picbasic.co.uk/

+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    217

    Default First try at DT_INT's, I failed! help please!

    Old dogs can learn new tricks, it just takes a little more effort. Can someone please tell me why the RB0 interrupt only works once on this simple routine? This is my first attempt at DT_INTís. Once I got MPASM set up on MCSP I thought it would be easy. Iím using X1 board with 16F877A and pulsing RB0 with a wire lead. It runs the leds once then will not run again. Iíve tried everything I can think of with no success.
    Code:
    define osc 20
        option_reg.6=1 'rising pulse
        wsave   var byte $70  system
        wsave1  var byte $A0  system
        wsave2  var byte $120 system
        wsave3  var byte $1A0 system
        i       var byte
        LEDS    Var PORTD   ' Alias PORTD to LEDS
        TRISD = %00000000       ' Set PORTD to all output
    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:
      PAUSE 1
      PortD=0
      GOTO Main
    '---[INT - interrupt handler]---------------------------------------------------
    ToggleLED1:  LEDS = 1        ' First LED on
            Pause 500       ' Delay for .5 seconds
            For i = 1 To 7  ' Go through For..Next loop 7 times
                    LEDS = LEDS << 1        ' Shift on LED one to left
                    Pause 500       ' Delay for .5 seconds
            Next i      
    @ INT_RETURN
          end

  2. #2
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    217


    Did you find this post helpful? Yes | No

    Default Re: First try at DT_INT's, I failed! help please!

    OK, I have found out that it is returning from the interrupt. However I can not interrupt again for about ten seconds or the interrupt fails. A failure to interrupt forces another ten second delay before I can trigger again. Is there anything I can do to speed this process? On compile the program shows only 255 words long. I don’t understand this time delay before I can re enter the interrupt. Comments please…

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


    Did you find this post helpful? Yes | No

    Default Re: First try at DT_INT's, I failed! help please!

    I’m using X1 board with 16F877A and pulsing RB0 with a wire lead.
    That's the problem.

    If you are using a wire to +5V, there's nothing to pull it back down.
    The pin will hold a charge, and will slowly drain off, allowing it to re-trigger after a few seconds.

    If you add a pull-down resistor it should work better.

    Or, you can turn on PORTB pull-ups (OPTION_REG.7 = 0), make PORTB.4 LOW so you can use SW1 pushbutton.
    Changing to OPTION_REG.6 = 0 will make it trigger on the falling edge (button press) instead of the rising edge (button release).
    Last edited by Darrel Taylor; - 5th January 2012 at 17:36.
    DT

  4. #4
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    217


    Did you find this post helpful? Yes | No

    Default Re: First try at DT_INT's, I failed! help please!

    Thanks Darrel, I'll give it a try!

  5. #5
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    217


    Did you find this post helpful? Yes | No

    Default Re: First try at DT_INT's, I failed! help please!

    Yep! works great!

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,256


    Did you find this post helpful? Yes | No

    Default Re: First try at DT_INT's, I failed! help please!

    Quote Originally Posted by Darrel Taylor View Post
    ...
    Or, you can turn on PORTB pull-ups (OPTION_REG.7 = 0), make PORTB.4 LOW so you can use SW1 pushbutton.
    Changing to OPTION_REG.6 = 0 will make it trigger on the falling edge (button press) instead of the rising edge (button release).
    This is funny, I did this very exercise yesterday and posted it in the Code Examples. LOL

    Robert

Posting Permissions

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