# Interrupt Trigger Inconsistency

**URL:** <https://forums.openmv.io/t/interrupt-trigger-inconsistency/1460>\
**Category:** OpenMV Boards\
**Created:** [October 31, 2019, 4:30am UTC](https://forums.openmv.io/t/interrupt-trigger-inconsistency/1460 "2019-10-31T04:30:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajeshktym](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@rajeshktym](https://forums.openmv.io/u/rajeshktym)\
**Post date:** [October 31, 2019, 4:30am UTC](https://forums.openmv.io/t/interrupt-trigger-inconsistency/1460/1 "2019-10-31T04:30:36Z")

</div>

```python
import time, pyb

from pyb import Pin

ms_count = 0
trigger_delay = []
def Average(lst): 
    return sum(lst) / len(lst) 

def callback(line):
    global ms_count
    global trigger_delay
    trigger_delay.append(ms_count)
    ms_count = 0

extint3 = pyb.ExtInt(pyb.Pin("P3") , pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_DOWN, callback)

while(True):
    time.sleep(1)
    ms_count += 1
    if len(trigger_delay)>3:
        average = Average(trigger_delay) 
        print(average,trigger_delay)
        trigger_delay.clear()

```

Hi, I am using above code for verify consistency of Interrupt trigger, but it give below result

- 358.25 [359, 357, 355, 362]  
354.75 [355, 356, 354, 354]  
353.75 [351, 355, 353, 356]  
357.75 [354, 357, 360, 360]  
357.0 [355, 356, 357, 360]  
358.5 [360, 356, 358, 360]  
357.5 [361, 358, 353, 358]  
357.75 [359, 358, 360, 354]  
352.75 [348, 351, 355, 357]  
357.5 [360, 357, 355, 358]  
355.5 [356, 360, 353, 353]  
355.5 [359, 357, 350, 356]  
352.5 [350, 354, 350, 356]  
355.0 [359, 353, 350, 358]  
357.0 [357, 358, 355, 358]  
353.75 [350, 352, 354, 359]  
355.0 [353, 356, 355, 356]  
355.5 [354, 354, 354, 360]  
356.25 [359, 357, 356, 353]  
357.0 [354, 360, 354, 360]  
356.75 [357, 355, 355, 360]  
357.75 [356, 362, 355, 358]  
353.75 [352, 354, 350, 359]  
357.0 [355, 359, 353, 361]  
354.25 [352, 357, 350, 358]

Is this normal or some thing I can improve though code?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [October 31, 2019, 6:01am UTC](https://forums.openmv.io/t/interrupt-trigger-inconsistency/1460/2 "2019-10-31T06:01:59Z")

</div>

If USB is connected then that will make the interrupt have jitter as the USB bus when being serviced has a higher priority.
