Skip to content

System Clock via RP2040/RP2350 TIMER

lbuild module: modm:platform:clock.timer

The RP2040 TIMER and the RP2350 TIMER0 are 64-bit counters incremented by a 1µs tick (the watchdog tick on the RP2040, the TICKS block on the RP2350) and shared by both cores. It is used to implement the modm::Clock::now() and modm::PreciseClock::now() interfaces defined in the modm:architecture:clock module without any interrupt.

Compared to the modm:platform:clock SysTick implementation, the clocks are correct on both cores, since the SysTick is core-local, and they keep counting while interrupts are masked.

modm::platform::TimerClock::initialize<SystemClock>();

The microsecond clock reads the lower 32-bit of the counter directly. The millisecond clock divides the 64-bit counter by 1000 with a multiply-shift, since the Cortex-M0+ has no 64-bit division and no 32x32=64-bit multiplication.

This module is only available for rp.

Dependencies

modm:platform:clock.timer modm_platform_clock_timer modm: platform: clock.timer modm_architecture_clock modm: architecture: clock modm_platform_clock_timer->modm_architecture_clock modm_ext_cmsis_device modm: ext: cmsis: device modm_platform_clock_timer->modm_ext_cmsis_device

Limited availability: Check with 'lbuild discover' if this module is available for your target!