User manual

...the world's most energy friendly microcontrollers
2012-04-24 - Giant Gecko Family - d0053_Rev0.96 522
www.energymicro.com
It is also possible to control the counter through either an external pin or PRS input. This is done through
the input logic for the Compare/Capture Channel 0. The Timer/Counter allows individual actions (start,
stop, reload) to be taken for rising and falling input edges. This is configured in the RISEA and FALLA
fields in TIMERn_CTRL. The reload value is 0 in up-count and up/down-count mode and TOP in down-
count mode.
The RUNNING bit in TIMERn_STATUS indicates if the Timer is running or not. If the SYNC bit in
TIMERn_CTRL is set, the Timer is started/stopped/reloaded (external pin or PRS) when any of the other
timers are started/stopped/reloaded.
The DIR bit in TIMERn_STATUS indicates the counting direction of the Timer at any given time. The
counter value can be read or written by software through the CNT field in TIMERn_CNT. In Up/Down-
Count mode the count direction will be set to up if the CNT value is written by software.
Figure 20.2. TIMER Hardware Timer/Counter Control
Counter
(Controlled by TIMERn_CTRL)
Com pare/Capture channel 0
(Controlled by TIMERn_CC0_CTRL)
TIMn_CC0
PRS channels
PRSSEL
INSEL
Filter
FILT
ICEDGE
Input
Capture 0
Counter
RISEA FALLA
Start
Stop
Reload&Start
20.3.1.3 Clock Source
The counter can be clocked from several sources, which are all synchronized with the peripheral clock
(HFPERCLK). See Figure 20.3 (p. 522) .
Figure 20.3. TIMER Clock Selection
Counter
(Controlled by TIMERn_CTRL)
Com pare/Capture channel 1
(Controlled by TIMERn_CC1_CTRL)
TIMn_CC1
PRS channels
PRSSEL
INSEL
Filter
FILT
ICEDGE
HFPERCLK
TIMERn
CLKSEL
Prescaler
PRESC
Input
Capture 1
Count er
20.3.1.3.1 Peripheral Clock (HFPERCLK)
The peripheral clock (HFPERCLK) can be used as a source with a configurable prescale factor of
2^PRESC, where PRESC is an integer between 0 and 10, which is set in PRESC in TIMERn_CTRL.
However, if 2x Count Mode is enabled and the Compare/Capture channels are put in PWM mode, the
CC output is updated on both clock edges so prescaling the peripheral clock will result in incorrect result.
The prescaler is stopped and reset when the timer is stopped.