Page 1 of 1

[stm32f411] sleep mode and irq button

Posted: Thu Jul 01, 2021 3:06 pm
by nesergen
Good day!
On my board I configured an irq interrupt button. I put the board into a light sleep mode. When a button is pressed during sleep, an interrupt and its associated function are triggered. And after activating waking up timer, another function is triggered. Here's my example:

Code: Select all

import machine, pyb

#пины с прерыванием 
tm0 = machine.Timer(mode=machine.Timer.PERIODIC, period = 100, callback = lambda x: pyb.LED(1).toggle())

def button_interrupt():
	print("Interruption...")
	tm0.deinit()
	tm0.init(mode=machine.Timer.PERIODIC, period = 1000, callback = lambda x: pyb.LED(1).toggle())

Button = pyb.Pin(pyb.Pin.board.PB4, pyb.Pin.IN, pyb.Pin.PULL_DOWN)# пин кнопка включения экрана
Button.irq( trigger=pyb.Pin.IRQ_RISING,  handler = lambda x: button_interrupt())


def wakeup_callback():
	tm0.deinit()
	tm0.init(mode=machine.Timer.PERIODIC, period = 5000, callback = lambda x: pyb.LED(1).toggle())


#--------start----------
print("Sleep interruption test...")
pyb.delay(5000) #delay for LED blink view

b_rtc = pyb.RTC()
b_rtc.wakeup(60000, lambda x: wakeup_callback() ) #плата засыпает (light_sleep) на X мин 
pyb.stop()
I'm wondering if it is possible to disable interrupts during sleep mode? I assumed that the board did not work during sleep and that it was necessary to set up wake-up in order to continue working. And here it turns out that the board is asleep, and some interruption works in the background and executes the commands assigned to it, it's strange. What is the meaning of such sleep?