Menu

Jump out of interrupt service subroutine

Help
viscomjim
2016-06-24
2016-06-24
  • viscomjim

    viscomjim - 2016-06-24

    Is it possible to jump to a different location in a program from the interrupt service routine? This is what I want to do...

    Dir SWITCH In
    SET IOCAN3 ON 'Waiting for negative going edge
    ON Interrupt PORTBCHANGE CALL ChangeMode

    Main:
    nop
    goto Main

    SubRoutine1
    do stuff
    end sub

    SubRoutine2
    do stuff
    end sub

    end

    TestLabel1:
    do stuff
    goto TestLabel1

    TestLabel2:
    do stuff
    goto TestLabel2

    SUB ChangeMode
    Set IOCAF3 OFF
    Mode += 1
    If Mode = 5 Then Mode = 1
    Select Case Mode
    Case 1
    SubRoutine1
    Case 2
    SubRoutine2
    Case 3
    goto TestLabel1
    Case 4
    goto TestLabel2
    end Select
    END SUB

    Latest GCB build. Using a 16f1825 that can have interrupt on neg. edge.

     

    Last edit: viscomjim 2016-06-24
  • Chris Roper

    Chris Roper - 2016-06-24

    Personaly I would use the interupt routeen to set a flag and have the Select Case Construct in the Main Loop.

    Jumping out of an interupt could leav context info on the stack which will eventualy overflow and crash.

    Cheers
    Chris

     
  • viscomjim

    viscomjim - 2016-06-24

    Excellent point Chris. Thanks!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.