How do I code an interrupt to act upon simultanious inputs?


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818

    Default How do I code an interrupt to act upon simultanious inputs?

    Hi Everyone,
    Can this be done, using 2 buttons which work to control existing sub programs,
    can I push them both so as to invoke an interrupt which would then clear the
    counter variables and cancel whichever subprogram is running, I may have as many as 4 or 5 different subprograms, i would like to cancel any of them by pressing these 2 buttons, I can do this with an AND gate and a seperate input pin on the PIC, But is there a way to code it without using the gate or the extra input pin?

    something like:
    IF PortA.0 AND PortA.1 >= 2 THEN
    ON INTERRUPT GOTO Cancel
    RESUME

    Cancel:
    ButtonVar1 = 0
    ButtonVar2 = 0
    RETURN

    Any input is Appreciated.
    Thanks
    JS

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    When an INTERRUPT (any interrupt) occurs, your program will jump to the part of your program designated as your Interrupt Service Routine. It is the job of your ISR to determine what caused the Interrupt and then act on it. You can only have ONE ISR jump point, but once you're inside your ISR, then you can check what caused the Interrupt and act on it. Interrupts have rules (like not allowing interrupts to interrupt interrupts I know it looks corny but it is gramatically correct!, and resetting Interrupt Flags), so it's better to read up on them before figuring how you're going to plan your code.

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default No Plan in effect

    Hi Melanie,
    Ya . . . actually I wasn't really in the planning stage yet, the psudo code posted was to give clarity to what I was attempting to do. As I understand it a pic cannot look at 2 simultanious inputs and make a descision based on that information. What I have tenitively decided to do is use a 7442 bcd decoder as switch decoder and buffer and use 1 pin of the pic as an interrupt input to clear the variables of all my for next counter loops(whichever one is running) if that will work. I am still too inexperienced in programming to know without trying if it will. I figure that's what breadboards are for. So I think my real question is, can a counter loop be decremented faster by code from outside the loop or by an interrupt driven event?

    Thank You again,
    JS

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Can you expand and give us the bigger picture.

    What are you counting, how many counters, how fast is this count?

    Are these push-buttons?

    Are you timing how fast a button is being pushed?

    What are you trying to achieve?

    Knowing a few more details would aid in giving advice.

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. I would like to make some code tmr0 and int(RB0) interrupt
    By chai98a in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 17th February 2006, 00:06
  5. Multi Interrupt How To ?
    By capitano in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd February 2005, 14:48

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