User manual
...the world's most energy friendly microcontrollers
2012-04-24 - Giant Gecko Family - d0053_Rev0.96 528
www.energymicro.com
Figure 20.14. TIMER Period and/or Pulse width Capture
0
Input
CNT
Clear&Start
Input Capture (frequency capture)
Input Capture (pulse-width capture)
20.3.2.4 Compare
Each Compare/Capture channel contains a comparator which outputs a compare match if the contents
of TIMERn_CCx_CCV matches the counter value, see Figure 20.15 (p. 528) . In compare mode, each
compare channel can be configured to either set, clear or toggle the output on an event (compare match,
overflow or underflow). The output from each channel is represented as an alternative function on the
port it is connected to, which needs to be enabled for the CC outputs to propagate to the pins.
Figure 20.15. TIMER Block Diagram Showing Comparison Functionality
TnCCR0[15:0
]
TnCCR1[15:0
]
Underflow
Compare Match x
TIMERn_TOPTIMERn_CNT
TIMERn_CCx
Update
Condition
Note: For simplicity, all
TIMERn_CCx registers are
grouped together in the figure,
but they all have individual
Compare Register and logic
=
= 0
=
=
TIMn_CC0
Compare and
PWM config
Compare and
PWM config
Compare and
PWM config
=
TIMn_CC1
TIMn_CC2
CNTCLK
Overflow
If occurring in the same cycle, match action will have priority over overflow or underflow action.
The input selected (through PRSSEL, INSEL and FILTSEL in TIMERn_CCx_CTRL) for the CC channel
will also be sampled on compare match and the result is found in the CCPOL bits in TIMERn_STATUS.
It is also possible to configure the CCPOL to always track the inputs by setting ATI in TIMERn_CTRL.
The COIST bit in TIMERn_CCx_CTRL is the initial state of the compare/PWM output. The COIST bit
can also be used as an intial value to the comapre outputs on a relaod-start when RSSCOIST is set in
TIMERn_CTRL. Also the resulting output can be inverted by setting OUTINV in TIMERn_CCx_CTRL. It
is recommended to turn off the CC channel before configuring the output state to avoid any pulses on
the output. The CC channel can be turned off by setting MODE to OFF in TIMER_CCx_CTRL.