← index #8586Issue #15806
Off-topic · high · value 0.264
QUERY · ISSUE

Long Timer Never Gets Called

openby patrick-collinsopened 2022-04-25updated 2022-04-26
port-rp2

On a Raspberry Pico a timer with a period of 300000 (5 minutes) gets called reliably while another timer with a period of 900000 (15 minutes) never gets called. Changing the period of task3 to 300000 gets it working again.

task1 = Timer()
task2 = Timer()
task3 = Timer()
task1.init(period=60000, mode=Timer.PERIODIC, callback=get_gnss)
task2.init(period=300000, mode=Timer.PERIODIC, callback=get_temperature)
task3.init(period=900000, mode=Timer.PERIODIC, callback=put_data)

CANDIDATE · ISSUE

TypeError: can't convert float to int

closedby aleferna12opened 2024-09-07updated 2024-09-07

Port, board and/or hardware

rp2, Pico W

MicroPython version

Version: MicroPython v1.23.0 on 2024-06-02; Raspberry Pi Pico W with RP2040

This works:

Timer(-1, mode=Timer.PERIODIC, period=1000, callback=lambda _: led.toggle())

But this doesn't:

Timer(-1, mode=Timer.PERIODIC, period=1000.0, callback=lambda _: led.toggle())

Error:

TypeError: can't convert float to int

Surprised me a lot, is this intended behaviour?

Cheers

Reproduction

from machine import *

led = Pin("LED", Pin.OUT)
# Some arguments are only accepted as integers! That's surprising
timer = Timer(-1, mode=Timer.PERIODIC, period=1000.0, callback=lambda _: led.toggle())

Expected behaviour

No response

Observed behaviour

Fails with: TypeError: can't convert float to int

Additional Information

No, I've provided everything above.

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