Skip to content

Why can not use IRQ in a new thread? #47

Closed
@jie-smile

Description

@jie-smile
from machine import Pin
import utime
import _thread

interruptCounter = 0
def callback(pin):
  global interruptCounter
  interruptCounter = interruptCounter+1
  
def foo():
    p16 = Pin(16, Pin.IN, Pin.PULL_UP)
    p16.irq(callback, Pin.IRQ_FALLING)
    while True:
        utime.sleep(1)
        

_thread.start_new_thread(foo, ())

while True:
    print(interruptCounter)
    utime.sleep(1)

The irq is not work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions