Page 1 of 1

reboot issue after disable_irq()

Posted: Sun Jul 21, 2019 4:06 pm
by sepp
Hello

I am not sure if I do something wrong.

I got a lolin esp8266 V3 (tried two boards)and compiled the latest firmware "MicroPython v1.11-167-g331c224e0-dirty on 2019-07-21; ESP module with ESP8266"

The code below reboots the board

Code: Select all

from time import sleep, sleep_ms
from machine import Pin, I2C, disable_irq, enable_irq, Timer

my_inter = False

def callback(pin):
    global my_inter
    my_inter = True

p_irq = Pin(13, Pin.IN)     # create input pin on GPIO13
p_irq.irq(trigger=Pin.IRQ_RISING, handler=callback)

state = disable_irq()
sleep_ms(4000)
print("after state = disable_irq()")
enable_irq(state)
print("after enable_irq(state)")
between disable_irq() and the print("after state = disable_irq()")
as long as I keep the sleep periode not longer than 3.5 secs it seems to work once but reboots on consecutive calls

Thank you for your advice and help

kind regards
Josef

Re: reboot issue after disable_irq()

Posted: Sun Jul 21, 2019 6:32 pm
by Roberthh
Looks like the watchdog barfed at you. You should see something like:

Code: Select all

 ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
You can easily force that with:

Code: Select all

from machine import disable_irq
state = disable_irq()

Re: reboot issue after disable_irq()

Posted: Sun Jul 21, 2019 7:02 pm
by sepp
Thank you Roberth

But I do not get it

In my code I have (does not fit in the code window)

Code: Select all

p_irq.irq(trigger=Pin.IRQ_RISING, handler=callback)

state = disable_irq()
sleep_ms(4000)
print("after state = disable_irq()")
enable_irq(state)
print("after enable_irq(state)")
and the WDT class is accordinǵ to the docs only available in pyboard, WiPy.
And after enabling debugging still no wdt reset

kind regards
Josef

Re: reboot issue after disable_irq()

Posted: Sun Jul 21, 2019 7:19 pm
by Roberthh
The ESP8266 RTOS has it's own watchdog, which is always enabled. What I am curious about is: why you would like to disable irq for a longer time? Typically that would be done for a time period as short as possible, like a few ms, or just a few python instructions.

P.S.: Longer code will have a scroll bar at the window.

Re: reboot issue after disable_irq()

Posted: Sun Jul 21, 2019 7:38 pm
by sepp
Hi

This is a lightning detector using AS 3935 over I2C. Works good
There are some quite stringent time limits (wait for longer than) when querying the chip after an interrupt and then logging this via syslog and via http to Domoticz. And so I figured it would be handy not getting interrupted by a new lightning while handling the old one.

But right now it runs without the disabled IRQ. I wait for the next thunderstorm.

Thank you
kind regards
Josef

Re: reboot issue after disable_irq()

Posted: Sun Jul 21, 2019 8:14 pm
by Roberthh
Instead of disabling interrupts, you can silence the interrupt handler. Pins can be reconfigured any time.

Re: reboot issue after disable_irq()

Posted: Mon Jul 22, 2019 6:01 am
by sepp
Hi Robert

...and that is what I do!

Thank you for your advise and help

kind regards
Josef