← index #17792Issue #17594
Off-topic · high · value 0.391
QUERY · ISSUE

OSError 16 from time.sleep_ms()

openby victorallumeopened 2025-07-31updated 2025-08-05
bugport-stm32

Port, board and/or hardware

stm32

MicroPython version

MicroPython v1.25.0

Reproduction

This is on a custom board. Code during the boot process calls time.sleep_ms(1100)

  1. Hard reset the board
  2. boot/main code starts running fine
  3. Break out to a repl
  4. (at this point, I can run time.sleep_ms() without problem)
  5. soft reset the board
  6. during the boot process, call to sleep_ms() fails

I cannot replicate the issue on v1.24.0 (i.e. something has changed going to v1.25.0)

Expected behaviour

No response

Observed behaviour

Call to time.sleep_ms() raises OSError 16 in the above conditions

Additional Information

This is running on a custom board with an STM32H743 MCU.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

RP2: time.sleep and time.sleep_ms waking early (but not time.sleep_us)

openby washleyopened 2025-07-01updated 2025-07-02
bugport-rp2

Port, board and/or hardware

RP2 (Pico 2W)

MicroPython version

MicroPython v1.25.0 on 2025-04-15; Raspberry Pi Pico 2 W with RP2350

Reproduction

sleep:

>>> for _ in range(0, 10): a = time.ticks_us() ; time.sleep(0.002) ; b = time.ticks_us() ; print(b - a) ;
... 
1900
1767
1883
1868
1882
1894
1918
1885
1902
1901

sleep_ms:

>>> for _ in range(0, 10): a = time.ticks_us() ; time.sleep_ms(2) ; b = time.ticks_us() ; print(b - a) ;
... 
1957
1782
1917
1881
1895
1883
1903
1902
1905
1899

sleep_us:

>>> for _ in range(0, 10): a = time.ticks_us() ; time.sleep_us(2000) ; b = time.ticks_us() ; print(b - a) ;
... 
2035
2033
2022
2022
2020
2021
2022
2021
2022
2027

Expected behaviour

Expecting sleep times to be at least the requested duration (except, of course, in the case of an exception being thrown).

Observed behaviour

thread.sleep and thread.sleep_ms wake early for this particular (2ms) duration, but thread.sleep_us does not.

Additional Information

I discovered this because an I2C sensor driver was intermittently failing due to not sleeping long enough when resetting a device (its code follows the sensor specification of waiting 2ms, or at least it tries to).

https://github.com/micropython/micropython/issues/15626 may or may not be related, I don't know nearly enough about micropython at this point to say.

Code of Conduct

Yes, I agree

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