interrupt problem....need help urgently


Closed Thread
Results 1 to 3 of 3
  1. #1
    johnson's Avatar
    johnson Guest

    Default interrupt problem....need help urgently

    dear all,

    I have some problem regarding using an interrupt. When an external interrupt occurs, I want the program counter to jump to the specific label instead of continue from the code that interrupt occured. Any suggestion?
    I wrote this in pic basic but it does not seem to be correct:


    disable
    isr:
    if (mode<=maxmode) then
    mode=mode+1
    intcon.1=0
    pause 50
    goto main
    endif
    enable



    the code shows that whenever interrupt occur, after operation the program should jump to main instead of continue the code.


    thanks in advance :>

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


    Did you find this post helpful? Yes | No

    Default

    Your example is NOT correct.

    When you jump to a Interrupt Service Routine with the ON INTERRUPT statement like so...

    ON INTERRUPT GOTO ISR

    you must treat this routine as if it was a subroutine, EXCEPT that with a subroutine it is exited with a RETURN, an Interrupt Service Routine MUST be exited with a RESUME.

    Optionally, the RESUME can have a label to jump to as in...

    RESUME ContinueFromHere

    or in your example you would have...

    RESUME Main

    but if the label is omitted, then you will resume from the point the program was 'interrupted'.

    So, if you specifically need to resume from a specific point, you do so by adding a label to the end of the RESUME statement as per my example above.

    If you fail to use a RESUME when exiting your ISR, then eventually you will have a stack overflow with unpredicatable results. Remember, with most PICs, your stack is only four levels deep... that means a TOTAL of FOUR subroutines and/or interrupts at any one point in time.

    Melanie

  3. #3
    johnson's Avatar
    johnson Guest


    Did you find this post helpful? Yes | No

    Default

    thanks a lot:>

Similar Threads

  1. Problem with Interrupt on PIC18F4620 PORTB
    By rookie in forum Off Topic
    Replies: 1
    Last Post: - 22nd March 2007, 01:34
  2. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 19:02
  3. Interrupt Problem
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th November 2005, 20:58
  4. Interrupt stack overflow problem with Resume {label}
    By Yuantu Huang in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 3rd May 2005, 01:17
  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 : 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