What's the interrupt latency and/or overhead when using DT-Ints?


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: What's the interrupt latency and/or overhead when using DT-Ints?

    As far as I know, if you have more than one INT_Handler, then it will take more time to do overhead checking on what label to jump, even if only one interrupt occurred. And further down the list it will take more time to jump to that label.
    ASM int header is faster "only" for save and restore time needed. Which is not small at all.
    From Re-EnterPBP-18 file, we can see that it need maximum 34 word to be saved and restored(can be less, depending on conditional assembling). Variables are grouped, so only one banksel instruction are needed.
    To save or restore 34 words(68 bytes) we need 136 instructions(one to load to W and one to load to F). I didn't check if PBP uses MOVFF, so maybe there is room for improvement.
    So worst case: just to save and restore PBP variables takes 280 instructions(272 movX instructions, +2 call, +2 returns, +2 banksel)
    Henrik's test program didn't have any IF then so didn't have any of T variables used, that is why it was faster.
    Last edited by pedja089; - 19th August 2016 at 01:03.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: What's the interrupt latency and/or overhead when using DT-Ints?

    I was going to say that the actual overhead can and will be different depending on what commands your program is using but compared to what's already there we're not talking about much. If it's really critical then my suggestion is to either measure it yourself or use the worst case number, which Pedja says is 280 instructions when not using LONGs.

    As for declaring the interrupt type as ASM while still using DT-ints the total (measured) overhead is around 7.6us - a difference of 8us or 128 instruction cycles. But if you're going to write the interrupt handler in assembly then you don't really need DT-Ints anyway and the overhead will become very small.

    Finally, the measurement shown here are all approximate, counting instruction cycles is Always a more accurate way, this was juse meant to visually show what's going on and put some sort of number on it for people who may be wondering.

    /Henrik.
    Last edited by HenrikOlsson; - 19th August 2016 at 23:23.

  3. #3
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: What's the interrupt latency and/or overhead when using DT-Ints?

    Nice Mostly, knowing the time you lost is important, rather than the fact you lost the instruction time itself,
    and all you really need to do is measure it. I think everyone should trim down anything like that.
    If you were only using DT Elapsed timer, and needed the second tick without counting Hours, Mins, Secs,
    you might as well remove the checks and get the instruction time back as any given project develops.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default Re: What's the interrupt latency and/or overhead when using DT-Ints?

    Nice job Henrik.

    It would be very interesting to see the timing on a modest PIC like F886 or similar. Will try this when in lab.

    Ioannis

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: What's the interrupt latency and/or overhead when using DT-Ints?

    Please do and post the results.
    It's going to be slightly worse on an old 14bit device since they don't have automatic context save/restore like the 18F devices do for high priority interrupts.

    /Henrik.

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default Re: What's the interrupt latency and/or overhead when using DT-Ints?

    Exactly because of that I am sure it will be much worse. Soon...

    Ioannis

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default Re: What's the interrupt latency and/or overhead when using DT-Ints?

    Finally I did the test on a 16F887 at 8MHz, and came up with a 49 usec to enter ISR and around 45 to exit.

    Name:  Latency.JPG
Views: 34535
Size:  46.3 KB

    The code I used is this:

    Code:
    wsave   var byte $70 system
    wsave1   var byte $A0 system
    wsave2   var byte $120 system
    wsave3   var byte $1A0 system
    
    
    INCLUDE "DT_INTS-14.bas"
    INCLUDE "ReEnterPBP.bas"
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR0_INT,  _TimezUp,   PBP,  yes
        endm
        INT_CREATE              ; Creates the interrupt processor
    ENDASM
    
    TRISB = %00000000           ' PortB.0 and PortB.1 are outputs.
    
    @ INT_ENABLE  TMR0_INT      ; Enable INT0 interrupts
    
    Main:
        portB.4 = !portb.4        ' Toggle PortB.1 as fast as we can
    Goto Main
    
    TimezUp:
        ' Create a short pulse on PortB.0
        portb.5 = 1
        PAUSEUS 15
        portB.5 = 0
    @ INT_RETURN
    It seems that comparing to 25K20, the 887 executes less instructions...? Is it possible?

    Ioannis
    Last edited by Ioannis; - 28th August 2016 at 11:50.

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, 19:27
  2. DT-INTs Interrupt handler question
    By circuitpro in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th January 2010, 01:06
  3. Issue with Array causing PauseUS to have 16uS overhead
    By bcd in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th November 2007, 09:41
  4. USART and interrupt latency - not a problem
    By barkerben in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 18th January 2005, 23:57
  5. Interrupt Latency - ASM vs. Basic
    By barkerben in forum General
    Replies: 5
    Last Post: - 1st January 2005, 22:09

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