← index #7849Issue #3994
Related · high · value 3.842
QUERY · ISSUE

STM32 sleep wake time problem

openby china-zhangdjopened 2021-09-24updated 2024-10-02
port-stm32
rtc.wakeup(ms)
machine.lightsleep(ms)

Do these two functions use the same wake-up source?
What is the maximum value of ms?

CANDIDATE · ISSUE

stm32: rtc.wakeup() freezes the system on F0 and L4 MCUs

closedby rolandvsopened 2018-07-30updated 2018-08-02
bugport-stm32

I tried this on a pyboard and it flashes the LED. Same program on the STM32L476_DISC port set the LED and freezes. Adapted it for the NUCLEO_F093RC and it also freezes.

Did anyone tested this functionality or can test this to confirm this behaviour?

import pyb
rtc = pyb.RTC()  # rtc is running

def lpdelay(ms):
    rtc.wakeup(ms)
    pyb.stop()
    rtc.wakeup(None)

led = pyb.LED(1)
while True:
    led.on()
    pyb.delay(1000)
    led.off()
    pyb.delay(1)
    lpdelay(1000)

For the NUCLEO_F093RC port using machine instead of pyb

import pyb, time, machine
rtc=pyb.RTC()

def lpdelay(ms):
    rtc.wakeup(ms)
    machine.sleep()
    rtc.wakeup(None)

led = pyb.LED(1)
while True:
    led.on()
    time.sleep_ms(1000)
    led.off()
    time.sleep_ms(1)
    lpdelay(1000)

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied