Interrupt block with different exit?


+ Reply to Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Jul 2024
    Posts
    28

    Default Interrupt block with different exit?

    Hi all,

    I'm troubleshooting an issue with an interrupt routine using RBC and Instant Interrupts where it's only detecting the first trigger and not any other following that.
    In my interrupt routine, when the interrupt is detected, the flag is cleared and there's a choice (IF...Then) that can lead the code to one of 2 options using GOTO.
    This means that after the interrupt, the code will not return to the point where the trigger was detected but somewhere else.
    That being said, I replaced the @ INT_RETURN with a couple of GOTOs.

    I found that replacing the @ INT_RETURN with GOTOs was causing the following triggers not being detected.
    If i replace the GOTOs with the @ INT_RETURN, the interrupts will work always.

    My question is...Is there a way i can do the jumps to where i want on the code and not being forced to return to where i was when the interrupt was triggered?

    Thanks
    Last edited by PaulMaker; - 5th February 2025 at 20:19.

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: Interrupt block with different exit?

    My question is...Is there a way i can do the jumps to where i want on the code and not being forced to return to where i was when the interrupt was triggered?
    no , the isr must return to the point it was triggered from. if you try manipulating the stack to alter the return address without the proper skillset and understanding it will always result in unpredictable behavior.
    if you structure your code to check frequently for a flag set from the isr that causes different processes to be invoked its possible to simulate the sort of result you are looking for
    Warning I'm not a teacher

  3. #3
    Join Date
    Jul 2024
    Posts
    28


    Did you find this post helpful? Yes | No

    Default Re: Interrupt block with different exit?

    Greetings Richard,

    thanks for the reply.
    I thought that the interrupt would still work (at least the detection part) even if we didn't want to go back to the code.
    In that case i will need to do what you are suggesting and add periodic checks (in the normal code sequence) for a flag change done by the interrupts.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default Re: Interrupt block with different exit?

    Hi,

    you can return wherever you want at the end of an interrupt stubb ...

    I did it some years ago ... but Darrel did not like it at all !!! ( )

    just have a look to the asm code generated and you will understand why and how !

    the trick lies on the DEFINE INTHAND + RESUME _Label use ...

    RESUME _Label gives

    - bsf Intcon.7
    - GOTO _Label

    and _ Label is a PBP stubb ... where you want to jump to ...

    for the moment, I have to dig out the program I wrote ...

    Alain
    Last edited by Acetronics2; - 6th February 2025 at 19:55.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default Re: Interrupt block with different exit?

    Yes, if you really, really know what you are doing and spend hours on the asm code to double and triple check the code flow.

    Ioannis
    Last edited by Ioannis; - 7th February 2025 at 07:15.

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: Interrupt block with different exit?

    it only works for and with ON INTERRUPT, and that's not a real interrupt
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: Interrupt block with different exit?

    Quote Originally Posted by richard View Post
    it only works for and with ON INTERRUPT, and that's not a real interrupt
    Hi, Richard

    just open your Holy Manual @ asm interrupts page ...

    as Ioannis states ... It's better to know what you are doing here ...

    Our friend Paul was just asking if it was possible

    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 2024
    Posts
    28


    Did you find this post helpful? Yes | No

    Default Re: Interrupt block with different exit?

    Hi guys,

    dos this makes any sense to you?
    I added a debugin line with timeout and jump label inside my interrupt block and this is causing the code not work as expected as well!

    RBCinterrupts:

    @ INT_DISABLE RBC_INT

    debug "trigger detected...", 13,10

    DEBUGIN 2000,JUMPOUT,[WAIT("MCU-"), DEC MOODCAP]

    debug "debugin passed...", 13,10


    RBIF=0
    INTFLAG=1


    DEBUG "returning...",13,10


    @ INT_RETURN
    Debugin jump block:


    JUMPOUT:


    DEBUG "fail debugin...",13,10

    @ INT_RETURN

Similar Threads

  1. Exit from an IF/ENDIF loop with a GOTO
    By aratti in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 17th February 2014, 13:05
  2. Capture loop exit
    By spcw1234 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th February 2012, 20:29
  3. ASM block does not compile
    By efarook in forum mel PIC BASIC
    Replies: 2
    Last Post: - 31st May 2008, 21:42
  4. Timer Interrupt to exit a closed loop
    By duncan303 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 16th December 2007, 16:45
  5. block comment?
    By eoasap in forum General
    Replies: 5
    Last Post: - 13th October 2005, 00:32

Members who have read this thread : 11

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