Jump from ISR


Closed Thread
Results 1 to 16 of 16

Thread: Jump from ISR

Hybrid View

  1. #1

    Default Jump from ISR

    Hi anyone.
    I am working on project and I've confronted with a problem. I want to jump from Interrupt service routine to subroutine and return from it and continue ISR.
    In other words is it possible in PBP to call a subrotine when program is executing ISR. Thanks for your reply.

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


    Did you find this post helpful? Yes | No

    Default

    Yes it's possible... case by case, just post your code here, tell us what you want to do, and we will be able to tell you better.
    Steve

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

  3. #3


    Did you find this post helpful? Yes | No

    Default My Code and Jump from ISR

    Hi dear Mister_e
    Thanks for your reply. Excuse me for delaying in my reply. I was too busy.
    Suppose that we have this program:

    Code:
    '*****************************************************************
    '*                         LCD Deifnes                           *
    '*****************************************************************    
        
        DEFINE LCD_DREG PORTD               ' I/O port where LCD is connected
        DEFINE LCD_DBIT 4
        DEFINE LCD_RSREG PORTD
        DEFINE LCD_RSBIT 2                  ' Register select pin
        DEFINE LCD_EREG PORTD
        DEFINE LCD_EBIT 3                   ' Enable pin
        DEFINE LCD_BITS 4                   ' 4-bit data bus
        DEFINE LCD_LINES 2                  ' LCD has 2 character lines
    
    	STATE 	var Byte
    	I 	var Byte
    	 	 
    	PORTA = 0
    	PORTB = 0
    '************************************************* ****************
    '* Interrupt Initialzing *
    '************************************************* **************** 
    
        INTCON     = %10001000 ' GIE and RBIE are set
        OPTION_REG = %10000000
    
    '************************************************* ****************
    '* Initialzation *
    '************************************************* ****************
    
        PORTB = 0
        TRISB = %00010000
    
        ON INTERRUPT GOTO DIRECTION
    
    '************************************************* ****************
    '* Main Program *
    '************************************************* ****************
    
    MAIN:
    
        lcdout $fe,1,"Main Routine"
    
        FOR I = 1 to 50 : PAUSE 10 : NEXT I ' For quick response
        GOTO MAIN
        END
    
    '************************************************* ****************
    '* Interrupt Service Routine *
    '************************************************* ****************
    
        DISABLE
    
    DIRECTION:
    
        STATE = PORTB	' End of Mismatch Condition
    
        lcdout $fe,1
        lcdout "Interrupt !!!"
    
        IF State.4 THEN
    
    	   LCDOUT $FE,$C0," LOW to HIGH "
    	
        ELSE
    
    	   LCDOUT $FE,$C0, " HIGH to LOW "
    	
        ENDIF
    	
        PAUSE 100
    
        INTCON.0 = 0
    
        RESUME
    
        ENABLE
    
        END
    When I want to move LCD display command out of ISR like below, the program doesn't work correctly!

    Code:
    '************************************************* ****************
    '* Interrupt Service Routine *
    '************************************************* ****************
    
        DISABLE
    
    DIRECTION:
    
        STATE = PORTB	' End of Mismatch Condition
    
        lcdout $fe,1
        lcdout "Interrupt !!!"
    
        IF State.4 THEN
    
    	   GOSUB L2H
    	
        ELSE
    
    	   GOSUB H2L
    	
        ENDIF
    	
        PAUSE 100
    
        INTCON.0 = 0
    
        RESUME
    
        ENABLE
    
        END
    
    L2H:
        LCDOUT $FE,$C0," LOW to HIGH "
        RETURN
    H2L:
        LCDOUT $FE,$C0," HIGH to LOW "
        RETURN

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


    Did you find this post helpful? Yes | No

    Default

    Just like with the ISR itself, ... any subroutines jumped to from the ISR must be DISABLED from further interrupts, or they will attempt to interrupt themselves.

    Moving the ENABLE line to after the H2L: subroutine should help.
    <br>
    DT

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Thanks alot
    Last edited by yasser hassani; - 2nd May 2008 at 12:26.

  6. #6


    Did you find this post helpful? Yes | No

    Default My problem is ...

    Thanks Dear Taylor
    If you see the first program you'll find out infact your suggestion (Moving the ENABLE line to after the H2L: subroutine should help) is used at it. My problem is about second program.
    Suppose that I want to implement this:
    When H2L occures, the program should start displaying contents of EEPROM (We call Address). Address increments one by one till interrupt L2H occures. Now program should start displaying Address again but in this subroutine Address decrements one by one. How can I do that?
    Please help me.
    Thanks alot.

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,651


    Did you find this post helpful? Yes | No

    Wink Expressing the "problem" is half way to solve it ...

    Hi, Yasser

    From reading your posts, I understand you want to scan your EEPROM, increasing address way, on a PORTB.4 H to L transition and decreasing addresses on a L to H transition ...

    Ok ...

    just use a FOR - NEXT EEPROM reading loop in the main program , if a "H2L" flag is set and a FOR-NEXT-STEP-1 EEPROM loop if a "L2H" flag is set.

    Note I use 2 flags to let the initial "no transition" condition usable for something Else...

    The ONLY questions will be : do you want to toggle reading order if EEPROM reading is not complete ???
    What will you do when EEPROM reading is complete ??? ( seems you wait for further transition ... )

    This has a strange smell of "K2000 scanner" or scrolling device ... really don't know why ... LOL !

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by yasser hassani View Post
    If you see the first program you'll find out infact your suggestion (Moving the ENABLE line to after the H2L: subroutine should help) is used at it. My problem is about second program.
    The second program is the one I was talking about.
    The subroutines are not DISABLE'd.
    <br>
    DT

Similar Threads

  1. DT-Ints latency and other interrupt conciderations
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 58
    Last Post: - 12th March 2010, 18:27
  2. ELSEIF Block Would be Good.
    By T.Jackson in forum PBP Wish List
    Replies: 30
    Last Post: - 14th May 2007, 03:36
  3. jump out from a for/next loop
    By Pedro Santos in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th March 2007, 15:50
  4. Jump into eeprom address
    By Lotondo in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 22nd April 2006, 18:29
  5. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59

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