QUERY · ISSUE
Long Timer Never Gets Called
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 · PULL REQUEST
Add freq arguement in machine.Timer.rst
docs
Timer has a freq arguement which is not methoned in the document.
- The timer class method
timer_settime(tid, hz)has a frequency arguments. And the period is in nano second accuracy. - Timer is triggered by Crystal Oscillator (XOSC). The STARTUP_DELAY register specifies how many clock cycles must be seen from the crystal before it can be used. This is specified in multiples of 256. That means in theory the max frequency is 12 MHz (crystal frequency) divided by 256, which is 46.875 MHz.
The following code is tested on Respberry Pi pico, using RP2040 microcontrollers.
from machine import Timer
speed = 2000
tim = Timer()
tim.init(freq=speed, mode=Timer.PERIODIC, callback=testSeqCallback)
Result supports arguement freq, and outputs correct signal.