DT-INTs What's legal in an INT handler?


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156

    Default DT-INTs What's legal in an INT handler?

    My program spends most of it's time in a loop waiting for an interrupt (button presses). Once received, I need to decode 24 buttons and execute the right commands.

    My present interrupt handler has a SELECT CASE function in it, with a GOSUB in every case to execute the functions. Is this legit? What are the specifics and restrictions in an interrupt handler?

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


    Did you find this post helpful? Yes | No

    Default

    With DT_INTS using a PBP type interrupt, pretty much anything goes. I.E. use as many
    PBP instructions as you like in the int handler.

    That's the really cool part of using DTs' int program. He's done all the work for you.

    Just don't GOSUB outside the interrupt handler - or it will go-like-splat...
    Last edited by Bruce; - 29th January 2010 at 01:54.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    Thanks Bruce. The issue that led me to this question is obviously something else.

    I'm using LONG variables for the first time, and have an issue where a bit in a 24-bit LONG is being changed/corrupted by me TOGGLEING another, unrelated BIT variable! I figured the problem is me MISDECLARING my variables OR my interrupt handler. Bit 14 of the LONG variable GRN is being corrupted when I toggle the bit variable SOLO. (If I don't use interrupts, the problem goes away).

    My variable declarations are:

    Code:
    RED         VAR     LONG                  
    GRN         VAR     LONG                  
    BUTTONS     VAR     LONG                  
    X           VAR     LONG                   
    Y           VAR     BYTE                    
    Z           VAR     BYTE                    
    RED0        VAR     RED.BYTE0
    RED1        VAR     RED.BYTE1
    RED2        VAR     RED.BYTE2
    GRN0        VAR     GRN.BYTE0
    GRN1        VAR     GRN.BYTE1
    GRN2        VAR     GRN.BYTE2                
    BU0         VAR     BUTTONS.BYTE0           
    BU1         VAR     BUTTONS.BYTE1         
    BU2         VAR     BUTTONS.BYTE2           
    LCD         VAR     BYTE[80]            
    COUNTER     VAR     BYTE                   
    VOL         VAR     BYTE                   
    SOLO        VAR     BIT
    Thanks.

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Bruce, could you please explain your comment to me? I would think that PBP knows what bank it is in, and keeps track of that - even in an interrupt handler. Is that not true?
    And what constitutes "outside the interrupt handler"? Must all the handler code be placed between the INT entry point and the INT_RETURN?
    I have to admit, I have violated your "rule" and it hasn't caused problems. Am I lucky?
    Please explain.
    Charles Linquist

  5. #5


    Did you find this post helpful? Yes | No

    Default

    ? toggle command is only good for port pins ?

  6. #6
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Smile

    Oh my gosh, you're right! I don't know why I thought that would work for a bit. That fixed it.

    THANKS Michael.

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Bruce, could you please explain your comment to me? I would think that PBP knows what bank it is in, and keeps track of that - even in an interrupt handler. Is that not true?
    And what constitutes "outside the interrupt handler"? Must all the handler code be placed between the INT entry point and the INT_RETURN?
    I have to admit, I have violated your "rule" and it hasn't caused problems. Am I lucky?
    Please explain.
    __________________
    Charles Linquist
    Hi Charles,

    Would be happy to answer if you could point me to the inital post...
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    This is a cut-and-paste from post #2 above.





    With DT_INTS using a PBP type interrupt, pretty much anything goes. I.E. use as many
    PBP instructions as you like in the int handler.

    That's the really cool part of using DTs' int program. He's done all the work for you.

    Just don't GOSUB outside the interrupt handler - or it will go-like-splat...
    __________________
    Charles Linquist

  9. #9
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    I wanted to clarify a point just to possibly help somebody else...

    Unfortunately, TOGGLE does work to change the state of a BIT variable, even though this is an incorrect use of the command! It also quite possibly clobbers some other unsuspecting variable, in this case a LONG. It would be nice if the compiler would flag it, but it doesn't so BEWARE!!

    Thanks again, Michael.

  10. #10
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Charles,

    What I meant was -- you don't want to jump outside an interrupt handler routine - without
    returning to it.

    I.E. if you GOSUB outside the interrupt routine, and don't re-enter it before your return, you might
    experience major problems.

    DT_INTS needs to exit from DT_INTS. If you jump outside of this routine, and try to return
    from the interrupt on-your-own, you're going to have a problem.

    Exit from an interruppt requires a lot of regitsers to be restored.

    If you jump outside of the int routine, and return on-your-own, you will for sure see a problem.
    Last edited by Bruce; - 29th January 2010 at 07:00.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  11. #11
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    I.E. if you GOSUB outside the interrupt routine, and don't re-enter it before your return, you might
    experience major problems.

    Code:
    ------------ DT Interrupt handler --------
    Get_Byte:
    
    do something here
    
    If black then gosub apples
    If withe then gosub peach
    
    @ return
    
    
    apples:
    do something
    return
    
    peach:
    do something
    return
    Bruce, can you please explain better your statement? from what you said, I understand that the above example code could give problems, while I am using this type of jump out of the interrupt handler, quite often and I never experienced any problem.

    Al.
    Last edited by aratti; - 29th January 2010 at 07:24.
    All progress began with an idea

  12. #12
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Al,

    No problem at all with your code. You GOSUB outside the int handler, and you RETURN right back to it, so this isn't a problem.

    The problem is only when you GOTO (or GOSUB) to another routine, outside an interrupt handler, and you do NOT return to it where it restores saved registers, and issues a RETFIE command.

    You show a DT Interrupt handler. You may not see it, but i guarantee theres a lot of code on exit from a DT interrupt routine
    that's restoring system file registers.
    Last edited by Bruce; - 29th January 2010 at 07:50.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  13. #13
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    I feel better now! I haven't broken any laws.
    Charles Linquist

  14. #14
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Bruce, tank you for the explanation.

    Al.
    All progress began with an idea

Similar Threads

  1. DT instant int error
    By mel4853 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th January 2010, 16:12
  2. Quick thoughts: DT Ints with encoders
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 7th January 2010, 01:01
  3. DT Ints work around for IOCA Register?
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th January 2010, 01:20
  4. Problem with Dt Ints Interrupts
    By Quin in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th July 2008, 19:21
  5. Replies: 1
    Last Post: - 2nd November 2006, 23:24

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