# How to disable one timer ISR and keep another timer running?

**URL:** <https://forums.openmv.io/t/how-to-disable-one-timer-isr-and-keep-another-timer-running/10066>\
**Category:** OpenMV Boards\
**Created:** [October 6, 2024, 12:09am UTC](https://forums.openmv.io/t/how-to-disable-one-timer-isr-and-keep-another-timer-running/10066 "2024-10-06T00:09:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjh2100](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/sjh2100/32/2979_2.png) [@sjh2100](https://forums.openmv.io/u/sjh2100)\
**Post date:** [October 6, 2024, 12:09am UTC](https://forums.openmv.io/t/how-to-disable-one-timer-isr-and-keep-another-timer-running/10066/1 "2024-10-06T00:09:29Z")

</div>

when i have code with several timer isr routine(for example T1,T2,T3), i want to stop or disable T2 and keep T1,T3 running. what should i do ?

---

<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 6, 2024, 2:10am UTC](https://forums.openmv.io/t/how-to-disable-one-timer-isr-and-keep-another-timer-running/10066/2 "2024-10-06T02:10:19Z")

</div>

Hi, can you post your code?

---

<div class="post-metadata">

**Author:** ![sjh2100](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/sjh2100/32/2979_2.png) [@sjh2100](https://forums.openmv.io/u/sjh2100)\
**Post date:** [October 6, 2024, 3:25am UTC](https://forums.openmv.io/t/how-to-disable-one-timer-isr-and-keep-another-timer-running/10066/3 "2024-10-06T03:25:45Z")

</div>

```auto
import os,machine,time,math
from pyb import LED,Switch,delay,Timer,Pin,ADC,DAC
from pyb import UART,ExtInt,disable_irq,enable_irq
def T1_isr(t):                
    global flag_500ms
    flag_500ms=1
    return
tim1 = Timer(1, freq=2,callback=T1_isr)
def T3_isr(t):  
	global flag_T4_next              
    LED(2).toggle()
	flag_T4_next=not flag_T4_next
    return
tim3 = Timer(3, freq=1,callback=T3_isr) 
def T8_isr(t):                
	LED(1).toggle()
    return
tim8 = Timer(8, freq=1,callback=T8_isr)
def T4_isr(t):                
    global flag_T4_next
    Isr_state=disable_irq()
    
    if flag_T4_next:
        tim4.period(500)
    else:
        tim4.period(1000) 
    tim4.counter(0)
    enable_irq(Isr_state)
    return
tim4 = Timer(4, prescaler=41,period=99,callback=T4_isr)
flag_T4_next=0
while(1):
	pass

```

---

<div class="post-metadata">

**Author:** ![sjh2100](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/sjh2100/32/2979_2.png) [@sjh2100](https://forums.openmv.io/u/sjh2100)\
**Post date:** [October 6, 2024, 3:31am UTC](https://forums.openmv.io/t/how-to-disable-one-timer-isr-and-keep-another-timer-running/10066/4 "2024-10-06T03:31:02Z")

</div>

i find the code of “cpsid(flags)” in [9. 各种指令 — MicroPython 1.9.4 文档](https://skidsdocs-lzy.readthedocs.io/zh-cn/latest/reference/asm_thumb2_misc.html) ,but there is no example about that. 🥵

---

<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 7, 2024, 3:48pm UTC](https://forums.openmv.io/t/how-to-disable-one-timer-isr-and-keep-another-timer-running/10066/5 "2024-10-07T15:48:04Z")

</div>

Yeah, I’m not sure what you are doing. You should generally schedule things to happen using [micropython – access and control MicroPython internals — MicroPython 1.23 documentation (openmv.io)](https://docs.openmv.io/library/micropython.html#micropython.schedule) from the ISRs and not do any work in the ISR.
