Timer
1. Overview
Each timer group (Timer0/Timer1) has three 32-bit up counters driven by a shared 4-bit prescaler. Timers can raise periodic interrupts or act as hardware clocks.
See: Timer Driver Guide
2. Code Path
CLI:
components/bk_cli/cli_timer.cDriver:
middleware/driver/timer/timer_driver.c
3. Configuration
Macros include CONFIG_TIMER (enable driver/CLI), CONFIG_TIMER_SUPPORT_ID_BITS (channel partition between CPUs), CONFIG_TIMER_US (microsecond delay APIs), and optional low-power callbacks.
4. Channel Mapping
No GPIO assignment required. Total of 6 channels:
CP: channels 0–2 (channel 2 feeds watchdog)
AP: channels 3–5
5. CLI Commands
Command |
Param |
Description |
|---|---|---|
|
|
Enable timer; ISR triggers periodically |
|
|
Read the counter value |
|
|
Read the programmed period value |
|
|
Stop the timer and disable its interrupt |
|
|
Set the enable bit |
|
|
Clear the enable bit |
6. Demo
Example flow on channel 3 (prefix with cpu1 for AP commands):
cpu1 timer 3 start 2000– start timer; ISR logs every 2 seconds.cpu1 timer 3 read– read counter.cpu1 timer 3 get_period– view programmed period value.cpu1 timer 3 stop– stop timer.cpu1 timer 3 enable/disable– toggle counting.