← index #4214Issue #5714
Related · high · value 2.434
QUERY · ISSUE

ESP32 port missing "hard" kwarg in pin.irq()

openby jedieopened 2018-10-05updated 2025-01-07
enhancementport-esp32

The ESP8266 has hard keyword argument in pin.irq() function. This is missing in ESP32 port.

See also: https://forum.micropython.org/viewtopic.php?p=30748#p30745

CANDIDATE · ISSUE

ESP8266 Pin IRQ regression

closedby peterhinchopened 2020-03-02updated 2020-05-02
port-esp8266

This device driver for IR remotes formerly worked on ESP8266. It now crashes with no changes to code. The problem is related to hard Pin IRQ's and the following code sample demonstrates it.

from machine import Pin
from time import sleep
import gc

pin = Pin(13, Pin.IN)
count = 0
def cb_pin(_):
    global count
    count += 1

ei = pin.irq(handler = cb_pin, trigger = (Pin.IRQ_FALLING | Pin.IRQ_RISING), hard = True)
# ei = pin.irq(handler = cb_pin, trigger = Pin.IRQ_FALLING, hard = True)

while True:
    sleep(1)
    print(count)
    gc.collect()

To test the pin is fed with a burst of 14 pulses of Manchester encoded data repeating every 104ms. Pulses are 889μs or 1778μs wide, the burst lasting 24.9ms. A crash with reboot occurs usually within a few seconds.

A crash also occurs if the commented-out code is used, ensuring that the minimum time between triggers is a leisurely 1.8ms. The crash takes longer to trigger.

Testing was with firmware built from source acquired today.
[EDIT]
I simplified the test by feeding the pin with a 20Hz square wave. The crash occurs after counting about 200 edges.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied