NXP Semiconductors
QN902x
User Manual of QN902x
UM10996
All information provided in this document is subject to legal disclaimers.
© NXP Semiconductors N.V. 2018. All rights reserved.
User Manual
Rev 1.3
— 05 November 2018
83 of 128
11.2.1
Clock Sources
The timer has two clock sources. One is the pre-scaled clock from clk_timer, which is
generated from the AHB clock. The other one is the external clock input from the GPIO.
The frequency of the scaled clock enable is calculated as follows:
_
1
clk timer
scled
f
f
PSCL
11.2.2
Input Capture Unit
The input capture unit is used to measure duration of the input signal from one edge to
another, in number of clock cycles of the timer clock. The triggering edge can be
configured as a positive edge, negative edge or both edges using the register bits
(ICES[1:0]). When the capture is triggered, the value of the counter is written to the
Capture/Compare Register (CCR). The Input Capture interrupt flag (ICF) is asserted at
the same time as the counter value is copied into the CCR register. If the interrupt is
enabled by register bit ICIE, the input capture flag will generate an interrupt to the
MCU.
To improve the noise immunity on the input signal, a noise canceller is added by using a
simple noise filter scheme, which can be enabled by setting the Input Capture Noise
Canceller Enable (ICNCE).
11.2.3
Compare Unit
TCNT
32/16-bit
comparator
A
P
B
B
U
S
ocf
CCR Buffer
CCR
cnt_en
Figure 11 Compare Unit
The 32/16-bit comparator continuously compares counter with the Compare/Capture
Register buffer (CCR Buffer). If TCNT equals CCR Buffer, the comparator signals a match.
The match will set the Output Compare Flag (OCF) at the next clock cycle of the timer. If
enabled (OCIE=1), the Output Compare Flag generates an output compare interrupt.
The interrupt can be software-cleared by setting corresponding bit.
The CCR and TOP registers are double buffered for supporting configure compare value
and top value on the fly and generating PWM waveform correctly.
11.2.4
PWM Waveform Generation
The PWM waveform can be generated upon the timer overflow or the compare match.
The period and duty cycle can be programmed.