I use pyb.ExtInt():
AlarmIntAB = pyb.ExtInt(17, pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_NONE, AlarmCallBack)
but the interrupts do not fire.
They do, however, when I set the EXTT_RTSR bit manually. That is, why I know the code itself is ok.
This is a dump of the registers for the external interrupts after pyb.ExtInt() has been called:
Code: Select all
EXTI_IMR 00000000 00000000 00100100 01000001
EXTI_RTSR 00000000 00000000 00100100 01000001
EXTI_FTSR 00000000 00000000 00000000 00000000
after calling AlarmIntAB.enable(), bit 17 is set - at least in the Interrupt Mask Register, but not in the Rising Trigger Selection Register.
Code: Select all
EXTI_IMR 00000000 00000010 00100100 01000001
EXTI_RTSR 00000000 00000000 00100100 01000001
EXTI_FTSR 00000000 00000000 00000000 00000000
But as soon as I set that bit manually:
stm.mem32[stm.EXTI + stm.EXTI_RTSR] |= 0b00000000000000100000000000000000 # Enable rising edge
It works like a charm.
Conclusion: pyb.ExtInt() sets the Alarm Callback, and resets(!) the IMR Register bit. The Rising and Falling Trigger Selection registers are ignored, regardless the second parameter setting.
What am I doing wrong?
Many thanks for your patience.