106 PSoC 4000 Family: PSoC 4 Architecture TRM, Document No. 001-89309 Rev. *D
Timer, Counter, and PWM
16.3 Modes of Operation
The counter block can function in six operational modes, as shown in Table 16-5. The MODE [26:24] field of the counter con-
trol register (TCPWM_CNTx_CTRL) configures the counter in the specific operational mode.
The counter can be configured to count up, down, and up/down by setting the UP_DOWN_MODE[17:16] field in the
TCPWM_CNT_CTRL register, as shown in Table 16-6.
Table 16-5. Operational Mode Configuration
Mode
MODE Field
[26:24]
Description
Timer 000
Implements a timer or counter. The counter increments or decrements by '1' at every counter clock cycle in
which a count event is detected.
Capture 010
Implements a timer or counter with capture input. The counter increments or decrements by '1' at every coun-
ter clock cycle in which a count event is detected. When a capture event occurs, the counter value copies into
the capture register.
Quadrature
Decoder
011
Implements a quadrature decoder, where the counter is decremented or incremented, based on two phase
inputs according to the selected (X1, X2 or X4) encoding scheme.
PWM 100 Implements edge/center-aligned PWMs with an 8-bit clock prescaler and buffered compare/period registers.
PWM-DT 101
Implements edge/center-aligned PWMs with configurable 8-bit dead time (on both outputs) and buffered com-
pare/period registers.
PWM-PR 110 Implements a pseudo-random PWM using a 16-bit linear feedback shift register (LFSR).
Table 16-6. Counting Mode Configuration
Counting Modes
UP_DOWN_
MODE[17:16]
Description
UP Counting Mode 00
Increments the counter until the period value is reached. A Terminal Count (TC) condition is
generated when the counter reaches the period value.
DOWN Counting Mode 01
Decrements the counter from the period value until 0 is reached. A TC condition is gener-
ated when the counter reaches ‘0’.
UP/DOWN Counting Mode 0 10
Increments the counter until the period value is reached, and then decrements the counter
until ‘0’ is reached. A TC condition is generated only when ‘0’ is reached.
UP/DOWN Counting Mode 1 11
Similar to up/down counting mode 0 but a TC condition is generated when the counter
reaches ‘0’ and when the counter value reaches the period value.