I have a question and hope that you can help me.
I am reading into ISR callbacks in the Micropython docs at the moment.
(https://docs.micropython.org/en/latest/ ... rules.html)
While the recommendation to allocate memory outside of the callbacks using
Code: Select all
array
Code: Select all
bytearray

And - everything works like a charm... I have no clue why or if this is some special case.
Can someone enlighten me? I really tried to break every rule I found in the docs and expected Python to complain like hell.
Code: Select all
from machine import Pin, I2C
import machine
import micropython
micropython.alloc_emergency_exception_buf(100)
a = []
class SomeThing:
pass
def callback(pin):
global a
a.append(True)
b = 2.2
x = SomeThing()
c = 4.4
print()
print(pin)
print(b + c)
p = machine.Pin(39, machine.Pin.IN, machine.Pin.PULL_UP)
trigger_all = Pin.IRQ_FALLING | Pin.IRQ_RISING
p.irq(trigger=trigger_all, handler=callback)
while True:
pass