reboot issue after disable_irq()

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
sepp
Posts: 6
Joined: Mon Jun 05, 2017 6:15 pm

reboot issue after disable_irq()

Post by sepp » Sun Jul 21, 2019 4:06 pm

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

User avatar
Roberthh
Posts: 1701
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: reboot issue after disable_irq()

Post by Roberthh » Sun Jul 21, 2019 6:32 pm

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()

sepp
Posts: 6
Joined: Mon Jun 05, 2017 6:15 pm

Re: reboot issue after disable_irq()

Post by sepp » Sun Jul 21, 2019 7:02 pm

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

User avatar
Roberthh
Posts: 1701
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: reboot issue after disable_irq()

Post by Roberthh » Sun Jul 21, 2019 7:19 pm

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.

sepp
Posts: 6
Joined: Mon Jun 05, 2017 6:15 pm

Re: reboot issue after disable_irq()

Post by sepp » Sun Jul 21, 2019 7:38 pm

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

User avatar
Roberthh
Posts: 1701
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: reboot issue after disable_irq()

Post by Roberthh » Sun Jul 21, 2019 8:14 pm

Instead of disabling interrupts, you can silence the interrupt handler. Pins can be reconfigured any time.

sepp
Posts: 6
Joined: Mon Jun 05, 2017 6:15 pm

Re: reboot issue after disable_irq()

Post by sepp » Mon Jul 22, 2019 6:01 am

Hi Robert

...and that is what I do!

Thank you for your advise and help

kind regards
Josef

Post Reply