MTB CAT1 Peripheral driver library
TCPWM (Timer Counter PWM)

General Description

The TCPWM driver is a multifunction driver that implements Timer Counter, PWM, Quadrature Decoder and Shift Register 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 seven function modes:

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

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:


PWM

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


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 Versions

There are three versions of TCPWM driver

TCPWM Version 3

TCPWM Version 2

tcpwm_v2_block_diagram.png
tcpwm_v2_input_trigger_sel.png
tcpwm_v2_trigger_simultaneously.png

TCPWM Version 1

tcpwm_v1_block_diagram.png
Note

More Information

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

Changelog

VersionChangesReason for Change
1.70 Newly added enum cy_en_copy_swap_config_t. Supported Glitch filter with configurable depth, HW look-up table for advance motor control, bug fixes and enhancement in reload and swap functionality.

Newly added APIs :

Updated the following APIs:

Newly added and updated enums:

Support for line select, HRPWM enhancements, enhancement in DT BUFF and SWAP ENABLE handling.
1.60 Newly Added Cy_TCPWM_OutputTriggerSetup API and code enhancement. Glitch filter support added for TCPWM version 3 and above.
1.50
  • Support for IP version 3.0.
  • Bug fixes.
  • Documentation update.
1.40 Support for CAT1B and CAT1D devices is added. No changes in public APIs interface and behavior. New devices support added.
1.30.1 Updated documentation of PWM mode. Documentation enhancement.
1.30 Added new option to Swap Overflow/Underflow behavior in PWM Centre/Asymmetric Alignment modes. New feature.
1.20 Added new features: Shift Register, New QuadDec modes, Additional Compare/Capture Buffer. New silicon family support.
1.10.2 Minor documentation updates. Documentation enhancement.
1.10.1 Added header guards CY_IP_MXTCPWM. To enable the PDL compilation with wounded out IP blocks.
1.10 Flattened the organization of the driver source code into the single source directory and the single include directory. Driver library directory-structure simplification.
Added register access layer. Use register access macros instead of direct register access using dereferenced pointers. Makes register access device-independent, so that the PDL does not need to be recompiled for each supported part number.
1.0.1 Added a deviation to the MISRA Compliance section. Added function-level code snippets. Documentation update and clarification
1.0 Initial version

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.