Timer
Overview
Ameba series products provide multiple timers for user applications:
RTL8721Dx:
10 Basic Timers:
TIM0-TIM7: Low-frequency Basic Timers (SDM32K clock source)
TIM10-TIM11: High-frequency Basic Timers (XTAL40M clock source)
1x 8-channel PWM Timer: TIM8
1x 1-channel Capture Timer: TIM9
1x 32-bit Debug Timer
2 sets of PMC Timers
RTL8720E:
13 Basic Timers:
TIM0-TIM7: Low-frequency Basic Timers (SDM32K clock source)
TIM10-TIM14: High-frequency Basic Timers (XTAL40M clock source)
1x 8-channel PWM Timer: TIM8
1x 1-channel Capture Timer: TIM9
1x 32-bit Debug Timer
RTL8710E:
13 Basic Timers:
TIM0-TIM7: Low-frequency Basic Timers (SDM32K clock source)
TIM10-TIM14: High-frequency Basic Timers (XTAL40M clock source)
1x 8-channel PWM Timer: TIM8
1x 1-channel Capture Timer: TIM9
1x 32-bit Debug Timer
RTL8726E:
13 Basic Timers:
TIM0-TIM7: Low-frequency Basic Timers (SDM32K clock source)
TIM10-TIM14: High-frequency Basic Timers (XTAL40M clock source)
1x 8-channel PWM Timer: TIM8
1x 1-channel Capture Timer: TIM9
1x 32-bit Debug Timer
RTL8713E:
13 Basic Timers:
TIM0-TIM7: Low-frequency Basic Timers (SDM32K clock source)
TIM10-TIM14: High-frequency Basic Timers (XTAL40M clock source)
1x 8-channel PWM Timer: TIM8
1x 1-channel Capture Timer: TIM9
1x 32-bit Debug Timer
RTL8730E:
12 Basic Timers:
TIM0-TIM7: Low-frequency Basic Timers (SDM32K clock source)
TIM10-TIM13: High-frequency Basic Timers (XTAL40M clock source)
1x 6-channel PWM Timer: TIM8
1x 1-channel Capture Timer: TIM9
1x 32-bit Debug Timer
RTL8721F:
4 Basic Timers: TIM0-TIM3 with software-configurable clock source (SDM32K/XTAL40M)
4x 4-channel PWM Timers: TIM4-TIM7
1x 1-channel Capture Timer: TIM8
1x 64-bit Debug Timer
2 sets of PMC Timers
RTL8735C:
4 Gtimer groups:
Group 0 and Group 2 each have 8 timers
Group 1 and Group 3 each have 1 timer
Total: 18 timers
Each timer features:
Count up and count down
Periodic and one-shot mode
4 match events
Prescaler
Basic Timer
Features
32-bit up-counter
Overflow interrupt generation
Preloadable auto-reload register
Sleep mode operation with interrupt wakeup capability
Application Examples
SDK provides two implementation types for Basic Timer:
mbed Examples
Path:
{SDK}\example\peripheral\mbed\Timer\mbed_gtimer\{demo}Demonstrates Basic Timer control in mbed environment
raw Examples
Path:
{SDK}\example\peripheral\raw\Timer\raw_gtimer\{demo}Demonstrates direct register-level Basic Timer control
Note
Check example’s README.md for supported chip information.
PWM Timer
Features
16-bit up-counter
Preloadable auto-reload register
16-bit programmable prescaler
Independent PWM generation per channel
Supported interrupts:
Counter overflow
Software update event
Channel counter overflow
Channel capture/compare
Operation modes:
PWM mode: Configurable duty cycle and period
Input capture: Edge-triggered counter capture
One-pulse mode: Programmable delayed pulse generation
Application Examples
SDK provides two implementation types for PWM Timer:
mbed Examples
Path:
{SDK}\example\peripheral\mbed\Timer\mbed_pwmDemonstrates PWM control in mbed environment
raw Examples
Path:
{SDK}\example\peripheral\raw\Timer\{demo}Demonstrates direct register-level PWM control
Key implementations:
raw_pwm: PWM mode demo
raw_tim_capture_pwm_32k: Input capture demo
raw_tim_pwm_one_pulse: One-pulse mode demo
Note
Check example’s README.md for supported chip information.
Capture Timer
Features
16-bit up-counter
16-bit programmable prescaler
Preloadable auto-reload register
Operation modes:
Pulse width measurement
Pulse counting within configurable window
Application Examples
SDK provides raw implementation examples for Capture Timer:
Path:
{SDK}\example\peripheral\raw\Timer\{demo}Demonstrates direct register-level capture control
Key implementations:
raw_tim_pulse_width_32k: Pulse width measurement
raw_tim_pulse_num_32k: Pulse counting implementation
Note
Check example’s README.md for supported chip information.
Debug Timer
Features
Dual clock sources:
XTAL40M: 1μs resolution (1MHz from 40MHz crystal)
SDM32K: 31μs step per 30.5μs period
Sleep mode persistence
A lock-free counter: atomic counter access for multi-core systems
PMC Timer
Features
RTL8721Dx:
2 sets of PMC Timers (each set contains 4 counters):
Sleep countdown counter
Deepsleep countdown counter
Wakeup counter
Reserved counter
32-bit width down counter (stops automatically when reaching 0)
Configurable interrupt generation upon reaching 0
SDM32K clock source
Timer countdown value can be reset during operation
RTL8720E:There is no PMC timer
RTL8710E:There is no PMC timer
RTL8726E:There is no PMC timer
RTL8713E:There is no PMC timer
RTL8730E:There is no PMC timer
RTL8721F:
2 sets of PMC Timers (each set contains 4 counters):
Sleep countdown counter
Deepsleep countdown counter
Wakeup counter
Reserved counter
32-bit width down counter (stops automatically when reaching 0)
Configurable interrupt generation upon reaching 0
SDM32K clock source
Timer countdown value can be reset during operation
RTL8735C:
4 sets of PMC Timers:
TIMER0 ~ TIMER3
32-bit width down counter (stops automatically when reaching 0)
Configurable interrupt generation upon reaching 0
SDM32K clock source
Compare mode: Timer set value takes effect only when greater than current counter value