Safely getting out of an interrupt


Closed Thread
Results 1 to 16 of 16
  1. #1
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219

    Default Safely getting out of an interrupt

    Working with DT interrupts(-14), Darrel stated many times to get out of the interrupt as soon as possible. I think this is because of the limited stack. So what exactly does it mean to get out of the interrupt? Of course INT_RETURN gets you out, but what if you don’t want to return to where you were interrupted? I would think that all that is needed is to clear the flag bit, am I wrong? Will this do the trick? Offhand I can’t think of anything else that DT may have done that must be dealt with.

    INT_Disable xxx_INT ;clear enable bit
    INT_CLEAR xxx_INT ;clear flag bit
    GOTO NewLocation
    Once you are at the new location you do a INT_Enable when ready for the next INT? I’m working with Hserin.
    Wayne

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


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    am I wrong?
    yes , totally


    interrupts are really a special type of gosub, one that can occur not from a set point in code space but one that occurs when an external stimulus occurs.
    secondly , a 14bit core chip has only one interrupt level only
    Warning I'm not a teacher

  3. #3
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    Richard,
    Thanks for responding.
    So, your saying there is more to the interrupt than saving Status, w, saving address, enabling bits, setting or clearing flags? I want to receive an interrupt RX_INT and as soon as the program has jumped to the Label ( _ReciveData), I can stop the interrupt routine, take care of business, then go to somewhere in the program other than the program location of that interrupt. If I use INT_Disable and INT_CLEAR what is left hanging? What else needs to be taken care of? I don't care about the old w, I don't care about the old status, I don't care about the old address. Please explain what i'm missing.
    Thanks,
    Wayne

  4. #4
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    richard,
    OK, so after I’ve thought about this perhaps its not my program that would have a problem but DT’s interrupt. If it acts as a special gosub then there may be some return address and flags that have to be taken care of. Is that correct? If so, how do you get out of it without using INT_RETURN?

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    the problem is that it then becomes a once only event , the pic will never branch to another interrupt.
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    If so, how do you get out of it without using INT_RETURN?
    it can't be done any other way except with a reset
    Warning I'm not a teacher

  7. #7
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    I believe you would have to POP the Stack, which is to remove the Saved Address the Interrupt was called from. Otherwise you'll eventually get Stack Overflow. If you only need that INT once after start-up, may not be an issue.

  8. #8
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    thanks for all the input. I've go to chew on this a while. perhaps DT_Handler macro may give some clues as to what would be required.
    Wayne

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    imagine driving down the road when ----
    "there's a Howard Johnsons! want to eat some clams?" (an interrupt occured new direction required)
    you turn the stering wheel to head towards the Howard Johnsons (the act of turning the wheel is the interrupt service) when the new direction is established you release the steering wheel car heads to the Howard Johnsons .
    your holding the steering wheel on full lock and asking how can i straighten up without letting the steering wheel return to normal
    its not goint to happen
    apologies to frank zappa (billie the mountain)
    Warning I'm not a teacher

  10. #10
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    Now I’m getting hungry! No Eldorado Cadillac. Not going to New York, Neeewwww Yooorrrrk!!! Did get drafted. Frank Zappa, Studebaker Hawk, RIP wherever you are!

  11. #11


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    so, on rcv-int.... save the character to mem or ram to work on in basic later, and raise some flag to be checked in basic that char is in system and leave int.... only takes few micro-seconds to bring chars into system. Can do a few machine code instructions to move character pointer, look for certain incoming character and/or reset character array in the int routine, again all few micro seconds depending on osc. Then always ready for next rcv.

  12. #12
    Join Date
    Aug 2011
    Posts
    408


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    then go to somewhere in the program other than the program location of that interrupt
    Perhaps the real question to ask is why do you feel you need to do that?

  13. #13
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    All I'm after is to transfer to a location other than where the INT occurred. I'm going to take a closer look at DT_INTs-14 and try to figure out if there are any system var that need to be dealt with. Other than that I think the only thing that is needed is to pop the stack and loose the address.

  14. #14
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    I think the only thing that is needed is to pop the stack and loose the address
    dream on

    typical stack implementation from data sheet core14 non enhanced pic
    4.3.2 STACK
    The PIC16F627A/628A/648A family has an 8-level
    deep x 13-bit wide hardware stack (Figure 4-1). The
    stack space is not part of either program or data space
    and the Stack Pointer is not readable or writable. The
    PC is PUSHed onto the stack when a
    CALL instruction
    is executed or an interrupt causes a branch. The stack
    is POPed in the event of a
    RETURN, RETLW or a
    RETFIE
    instruction execution. PCLATH is not affected
    by a PUSH or POP operation.





    Note
    1: T
    here are no Status bits to indicate stack overflow or stack underflow conditions.2:There are no instructions/mnemonics called PUSH or POP. These are actions that occur from the execution of the
    CALL, RETURN, RETLW and RETFIE instructions, or the vectoring to an interrupt address.







    Warning I'm not a teacher

  15. #15
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    A safer approach is to simply have the interrupt set a flag and return. You main program can be a tight loop that checks flags. When to detects the flag, it GOSUBs to the new location.

  16. #16
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Safely getting out of an interrupt

    Code:
    ;Interrupt Processor:
    ASM
    INT_LIST  macro    ; IntSource,  Label,     Type, ResetFlag? 
            INT_Handler   INT_INT,   _OK,       PBP,  yes   ;USART CS
            INT_Handler   AT1_INT,   _Fire,     PBP,  yes   ;Fires Coil
            INT_Handler   IOC_INT,   _Wipe,     PBP,  yes   ;Fires Output
            INT_Handler   RX_INT,    _Grab,     PBP,  yes   ;USART Transmission Received
            INT_Handler   T1G_INT,   _Get_RPM,  PBP,  yes   ;Count Pulses to Determine RPM
            INT_Handler   TMR3_INT,  _Stall,    PBP,  yes   ;RPM Below Limits of TMR1
        endm
        INT_CREATE                      ;Creates the interrupt processor
    ENDASM
    This is a typical DT_INT Declaration. As you can see, when an external interrupt occurs the program jumps to a Label called "OK". When an Angular Timer Interrupt occurs it jumps to "Fire". Each Interrupt has a different Label the DT_INT INCLUDE will sent the PC to. An IOC INT directs the PC to "Wipe", and so forth. This may be the part you missed based on your comment,

    "All I'm after is to transfer to a location other than where the INT occurred."

Similar Threads

  1. Replies: 0
    Last Post: - 27th August 2004, 08:20

Members who have read this thread : 2

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