Concise Overview of Raspberry Pi Pico Timers: Overview & APIs
RP2040 timing units overview & MicroPython Timer / PWM class APIs.
COMPONENTS
PROJECT DESCRIPTION
【Preliminary Note】The original hardware example in this article was written based on the RP2040. The actual hardware used in this hands-on demonstration features the W55RP20 as the main controller chip. The circuit logic and UF2 flashing operation principles are universally applicable, with only the main controller model differing. The original chip model mentioned in the circuit descriptions below is provided for reference purposes only.
1. Overview of the Raspberry Pi Pico Timer
Simply put, the Raspberry Pi Pico features the following timing units:
One 64-bit general-purpose timer with independent incrementing function and a frequency of 1 MHz
8 16-bit programmable PWM timers, with all pins capable of generating PWM signals
1 Systick system tick timer
A down-counting watchdog timer
1 RTC (Real-Time Clock)
A 32-bit timer inside the PIO finite-state machine that can generate interrupts, with a frequency equal to the system clock frequency
There are four internal pacing timers inside the DMA, which can trigger transmission periodically
2. Software Control Method
2.1 Constructor method of the machine. Timer class
The constructor of the machine. Timer class is as follows:
2.2 Other Methods of the machine. Timer Class
The machine. Timer class also features initialization and deinitialization methods:
2.3 Constructor method of the machine. PWM class
The constructor method of the machine. PWM class is as follows:
2.4 Other Methods of the machine. PWM Class
The other methods of the machine. PWM class are as follows: