PSOC E8XXGP Device Support Library

| PSOC E8XXGP Device Support Library

API Reference
TCPWM (Timer Counter PWM)
PDL API Reference

## General Description

The TCPWM driver is a multifunction driver that implements Timer Counter, PWM, Quadrature Decoder, Shift Register and Motion Interface functionality using the TCPWM block.

The functions and other declarations used in this driver are in cy_tcpwm_counter.h, cy_tcpwm_pwm.h, cy_tcpwm_quaddec.h, cy_tcpwm_shiftreg.h respectively. Include cy_pdl.h to get access to all functions and declarations in the PDL.

Each TCPWM block is a collection of counters that can all be triggered simultaneously. For each function call, the base register address of the TCPWM being used must be passed first, followed by the index of the counter you want to touch next.

The TCPWM supports eight function modes:

- Timer
- Capture
- Quadrature Decoder
- Pulse Width Modulation (PWM)
- PWM with dead time insertion (PWMDT)
- Pseudo random PWM (PWMPR)
- Shift Register

The TCPWM driver is structured to map these seven functional modes to four high level operating modes:

- Timer/Counter (includes Timer, Capture modes)
- PWM (PWM, PWMDT, PWMPR)
- Quadrature Decoder
- Shift Register

A brief description on each of the operating modes:

Timer/Counter

Use this mode whenever a specific timing interval or measurement is needed. Examples include:

- Creating a periodic interrupt for running other system tasks
- Measuring frequency of an input signal
- Measuring pulse width of an input signal
- Measuring time between two external events
- Counting events
- Triggering other system resources after x number events
- Capturing time stamps when events occur

PWM

Use this mode when an output square wave is needed with a specific period and duty cycle, such as:

- Creating arbitrary square wave outputs
- Driving an LED (changing the brightness)
- Driving Motors (dead time assertion available)

Quadrature Decoder

A quadrature decoder is used to decode the output of a quadrature encoder. A quadrature encoder senses the position, velocity, and direction of an object (for example a rotating axle, or a spinning mouse ball). A quadrature decoder can also be used for precision measurement of speed, acceleration, and position of a motor's rotor, or with a rotary switch to determine user input.
Shift Register

Shift Register functionality shifts the counter value to the right. A shift register is used to apply a signal delay function which can be used eg: in detecting frequency shift keying (FSK) signals. A shift register is also used in parallel-in to serial-out data conversion and serial-in to parallel-out data conversion.

# TCPWM Version

TCPWM Version 2

- Supports up to four counter groups (check TRM for actual number of groups supported)
- Each counter group consists of up to 256 counters (check TRM for actual number of counters supported)
- Each counter
  - Can run in one of seven function modes
  - Supports various counting modes:
    - One-shot mode, Continuous mode (Up/Down/Up-down)
  - Selects input signals
    - Start, Reload, Stop, Count, and two Capture event signals
  - Generates output signals:
    - Two output triggers, PWM output, and Interrupt
  - Trigger Outputs (TR_OUT0/1) and an Interrupt on an event
    - Overflow (OV)
    - Underflow (UN)
    - Terminal Count (TC)
    - CC0/1_MATCH
    - LINE_OUT
  - Supports debug mode
  - Each counter can produce two output signals

- Input Trigger Selection and Event Detection
  - The counter control signals are generated as follows:
    - Selects input signals from two types of trigger multiplexer signals
      - Group trigger and one-to-one trigger
      - The constant '1' and '0' are also used as input triggers
    - Detects the selected edge from four types
      - Rising edge/falling edge/any edge/no edge
    - Supports software (SW) command
      - SW command of Trigger Multiplexer/SW command of TCPWM

- Simultaneous Activation:
  - When a Trigger Multiplexer block SW command is used, the TCPWM counters can be activated at the same time

# More Information

For more information on the TCPWM peripheral, refer to the technical reference manual (TRM).

## API Reference
| Common
| Common API for the Timer Counter PWM Block.
| Timer/Counter (TCPWM)
| Driver API for Timer/Counter.
| PWM (TCPWM)
| Driver API for PWM.
| Quadrature Decoder (TCPWM)
| Driver API for Quadrature Decoder.
| Shift Register (TCPWM)
| Driver API for Shift Register.