Change On Interrupt, PIC16F884


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    Join Date
    Apr 2005
    Location
    Virginia
    Posts
    65


    Did you find this post helpful? Yes | No

    Question Multiple Resumes not working

    Joe, thanks for the info!

    Okay, related to interrupts, I've run into another problem. I go into my interrupt routine, detect a button on a port change and then tell the program to resume at a new routine based on which button was pressed. The first button works fine, but whenever I press the second button, it seems to ignore/skip the resume (colored below) and go on to the end of the interrupt routine. I added a toggle to an LED to indicate where the program was going. It works before the colored resume statement and after the end if statement, but not immediately after the resume statement. I also tried it at the beginning of the Score_player2 routine, which of course didn't work. I tried a quick search on the forum, but didn't come across anything similar, at least not yet. Any reason PBP would skip or ignore a resume statement? I've just included the interrupt routine - the rest is very similar to the code posted above.

    I don't know if this is an indication of another problem, but I'm multiplexing two seven segment digits and whenever I press either button, one of the digits goes out, sometimes digit A and sometimes digit B regardless of the button pressed, and comes back on whenever I release the button.

    '************************************************* ************************************************** ***
    DISABLE ' do NOT place interrupt checking code below
    Halt: ' Halt Routine
    temp = PORTB
    TOGGLE PORTE.1
    IF temp.0 = 0 THEN
    WHILE PORTB.0=0 ' wait for button release & end mismatch condition on portb
    WEND
    PAUSE 20 ' Debounce delay
    INTCON.0 = 0 ' Clear the interrupt-on-change flag
    RESUME SCORE_PLAYER1
    ENDIF
    IF temp.1 = 0 THEN
    WHILE PORTB.1=0 ' wait for button release & end mismatch condition on portb
    WEND
    PAUSE 20 ' Debounce delay
    INTCON.0 = 0 ' Clear the interrupt-on-change flag
    RESUME SCORE_PLAYER2
    ENDIF
    INTCON.0 = 0 ' Clear the interrupt-on-change flag
    RESUME Main ' Go to Main routine
    ENABLE ' Enable all active interrupts
    '************************************************* ************************************************** ***

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Not a good idea to me to use label with RESUME as you never know where the program was before to jump in the ISR. You should jump (goto) at the end if your ISR, then your program will return where he was before.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Apr 2005
    Location
    Virginia
    Posts
    65


    Did you find this post helpful? Yes | No

    Thumbs up

    Steve,

    I'd be lying if I said I completely understood what you meant, but I noticed that I was forcing the program to resume at the start of the Main routine and allowed it to just resume at the end of the ISR. It works! Thank you for your advice. I still have one of the digits going off whenever I press a button, but I'll investigate that further. Likely a hardware issue.

    '************************************************* ************************************************** ***
    DISABLE ' do NOT place interrupt checking code below
    Halt: ' Halt Routine
    temp = PORTB
    TOGGLE PORTE.1
    IF temp.0 = 0 THEN
    WHILE PORTB.0=0 ' wait for button release & end mismatch condition on portb
    WEND
    PAUSE 20 ' Debounce delay
    INTCON.0 = 0 ' Clear the interrupt-on-change flag
    RESUME SCORE_PLAYER1
    ENDIF
    IF temp.1 = 0 THEN
    WHILE PORTB.1=0 ' wait for button release & end mismatch condition on portb
    WEND
    PAUSE 20 ' Debounce delay
    INTCON.0 = 0 ' Clear the interrupt-on-change flag
    RESUME SCORE_PLAYER2
    ENDIF
    INTCON.0 = 0 ' Clear the interrupt-on-change flag
    RESUME ' Resume program running before interrupt occurred
    ENABLE ' Enable all active interrupts
    '************************************************* ************************************************** ***

Similar Threads

  1. A Simple IOC Routine (Interrupt On Change)
    By lugo.p in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th March 2010, 19:53
  2. 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
  3. 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
  4. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 0

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