ESP8266 - rst cause:2
Posted: Sat Jul 08, 2017 6:14 pm
Hi,
I'm trying to run simple code measuring signal frequency(around 1kHZ to 2kHz) by counting rising edges and returning their divided by time period number. After some time(from 1s to up to 20s - seems kinda random) ESP8266 board is being reset with rst cause: 2 and boot mode:(3,7).
Here is program I'm trying to run:
import machine
PERIOD = 1000
number = 0
def increase(p):
global number
number+=1
def count(p):
global number, PERIOD
print(number/(PERIOD/1000))
number = 0
btn = machine.Pin(2, machine.Pin.IN, machine.Pin.PULL_UP)
tim = machine.Timer(-1)
tim.init(period=PERIOD, mode=machine.Timer.PERIODIC, callback=count)
btn.irq(trigger=machine.Pin.IRQ_RISING, handler=increase)
My best guess would be that it's caused by colliding timer and interrupt events. Is something wrong with my program? Can anything be done to stop board from reseting?
I'm trying to run simple code measuring signal frequency(around 1kHZ to 2kHz) by counting rising edges and returning their divided by time period number. After some time(from 1s to up to 20s - seems kinda random) ESP8266 board is being reset with rst cause: 2 and boot mode:(3,7).
Here is program I'm trying to run:
import machine
PERIOD = 1000
number = 0
def increase(p):
global number
number+=1
def count(p):
global number, PERIOD
print(number/(PERIOD/1000))
number = 0
btn = machine.Pin(2, machine.Pin.IN, machine.Pin.PULL_UP)
tim = machine.Timer(-1)
tim.init(period=PERIOD, mode=machine.Timer.PERIODIC, callback=count)
btn.irq(trigger=machine.Pin.IRQ_RISING, handler=increase)
My best guess would be that it's caused by colliding timer and interrupt events. Is something wrong with my program? Can anything be done to stop board from reseting?