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


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219

    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
    219


    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 18:36.
    DT

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


    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
    219


    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,588


    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

Members who have read this thread : 1

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