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 ?
Hi, can you post your code?
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
i find the code of “cpsid(flags)” in 9. 各种指令 — MicroPython 1.9.4 文档 ,but there is no example about that.
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) from the ISRs and not do any work in the ISR.