User's Manual
RYZ012 Multi-Standard Wireless Communication Module for Bluetooth 5 Low Energy and 802.15.4
R15UH0002EU0103 Rev.1.03 Page 96 of 206
Apr.21.21
Timer 0 starts counting upward, and Tick value is increased by 1 on each positive edge of system clock until it reaches Timer0 Capture value.
10.1.2 Mode 1 (GPIO Trigger Mode)
In Mode 1, GPIO is employed as clock source. The registers
GPIOx:T0G2R, GPIOx:T1G2R or GPIOx:T2 specify the GPIO that generates the
counting signal for Timer 0, Timer 1 and Timer2, respectively.
When the timer is enabled, Timer Tick (that is counting value) is increased by 1 on each positive/negative (configurable) edge of GPIO.
Generally, the initial Tick value should be set to 0. The
GPIOx:INTPOL register specifies the GPIO edge when Timer Tick counting increases.
See
GPIO to Timer and Interrupt Mapping for GPIO to timer mapping.
Once current Timer Tick value matches the preset Timer Capture (that is timing value), an interrupt is generated and timer stops counting.
10.1.2.1 Timer 1 Mode 1 Configuration Example
1. Set initial Tick value of Timer1 through
TIMER:TICK1. It is recommended to clear initial Timer Tick value to 0.
2. Set the Capture Value of Timer 1 through
TIMER:CAPT1.
3. Select GPIO source and edge for Timer1 through registers
GPIOx:T1G2R and GPIOx:INTPOL.
4. Set Timer 1 to Mode 1 and enable Timer 1 by setting TIMER:CTRL:MODE1 to 2b'01 and TIMER:CTRL:EN1 to 1b'1.
Timer 1 starts counting upward, and Timer1 Tick value is increased by 1 on each positive/negative (specified during the 3rd step) edge of GPIO
until it reaches Timer1 Capture value.
10.1.3 Mode 2 (GPIO Pulse Width Mode)
In Mode 2, system clock is employed as clock source to measure the width of GPIO pulse. The registers
GPIOx:T0G2R, GPIOx:T1G2R or
GPIOx:T2 specify the GPIO that generates the control signals for Timer 0, Timer 1 and Timer 2, respectively.
When the Timer is enabled, Timer Tick is triggered by a positive/negative (configurable) edge of GPIO pulse. Then Timer Tick (that is counting
value) is increased by 1 on each positive edge of system clock. Generally, the initial Tick value should be set to 0. The GPIOx:INTPOL register
specifies the GPIO edge when Timer Tick starts counting. See
GPIO to Timer and Interrupt Mapping for GPIO to timer mapping.
When a negative/positive edge of GPIO pulse is detected, an interrupt is generated and timer stops counting. The GPIO pulse width could be
calculated in terms of tick count and period of system clock.
10.1.3.1 Timer 2 Mode 2 Configuration Example
1. Set initial Timer 2 Tick value through
TIMER:TICK2. It is recommended to clear initial Timer Tick value to 0.
2. Select GPIO source and edge for Timer 2 through registers GPIOx:T2 and GPIOx:INTPOL.
3. Set Timer 2 to Mode 2 and enable Timer 2 by setting
TIMER:CTRL:MODE2 to 2b'10 and TIMER:CTRL:EN2 to 1b'1.
Timer 2 Tick is triggered by a positive/negative (specified during the 2nd step) edge of GPIO pulse. Timer 2 starts counting upward and its Tick
value is increased by 1 on each positive edge of system clock.
When a negative/positive edge of GPIO pulse is detected, an interrupt is generated and Timer 2 stops counting.
The length of the GPIO pulse is determined as the system clock period time multiplied with the value read from register
TIMER:TICK2.
10.1.4 Mode 3 (Tick Mode)
In Mode 3, the system clock is employed as clock source. When the Timer is enabled, Timer Tick starts counting upward, and Timer Tick value
is increased by 1 on each positive edge of system clock.
This mode can be used as time indicator. There will be no interrupt generated. Timer Tick keeps rolling from 0 to 0xffffffff. When Timer tick
overflows, it returns to 0 and starts counting upward again.