8000 extmod/uasyncio Interface to ISR is problematic · Issue #6415 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content
extmod/uasyncio Interface to ISR is problematic #6415
Closed
@peterhinch

Description

@peterhinch

This arose from this forum post. The following code sample only runs the task scheduled by the ISR when the one running task wakes up. Tested on a Pyboard 1.1 running firmware V1.13.

import uasyncio
from machine import Pin
import micropython

async def example_task():
    print('example task running')

def task_launcher(_):
    print('task_launcher running')
    uasyncio.create_task(example_task())

def irq_handler(pin):
    print('IRQ!', pin.value())
    micropython.schedule(task_launcher, None)

trigger = Pin(Pin.board.X6, Pin.IN, Pin.PULL_UP)
trigger.irq(irq_handler, Pin.IRQ_FALLING | Pin.IRQ_RISING)

async def endless_loop():
    while True:
        print('Tick.')
        await uasyncio.sleep(5)
        print('Tock.')
        await uasyncio.sleep(5)

uasyncio.run(endless_loop())

Given that #6106 is not merged, the problem can't be fixed with an Event.

Is there a way to interface uasyncio with an ISR other than a busy-wait loop?

Metadata

Metadata

Assignees

No one assigned

    Labels

    extmodRelates to extmod/ directory in source

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0