MTB CAT1 Peripheral driver library
Shift Register (TCPWM)

General Description

Driver API for Shift Register.

The functions and other declarations used in this part of the driver are in cy_tcpwm_shiftreg.h. You can also include cy_pdl.h to get access to all functions and declarations in the PDL.

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.

Features:

Note
Shift Register mode is available only in TCPWM Version 2

Configuration Considerations

The Shift Register configuration can be divided to number of sequential steps listed below:

Configure Shift Register

To configure Shift Register, provide the configuration parameters in the cy_stc_tcpwm_shiftreg_config_t structure. The configuration structure can be modified through software, but if the configurator in ModusToolbox is used then the configuration structure will be updated with the users inputs. To initialize the driver, call Cy_TCPWM_ShiftReg_Init function providing a pointer to the populated cy_stc_tcpwm_shiftreg_config_t structure.

/* Scenario: Initialize the first (index = 0) of TCPWM 0 block
* as Shift Register with configuration settings
*/
{
/* .clockPrescaler = */CY_TCPWM_SHIFTREG_PRESCALER_DIVBY_1,
/* .tapsEnabled = */0x80000000UL,
/* .compare0 = */16384UL,
/* .compareBuf0 = */16384UL,
/* .enableCompare0Swap = */false,
/* .compare1 = */16384UL,
/* .compareBuf1 = */16384UL,
/* .enableCompare1Swap = */false,
/* .interruptSources = */CY_TCPWM_INT_ON_CC0, /* Interrupt will rise on CC0 Match*/
/* .invertShiftRegOut = */CY_TCPWM_SHIFTREG_INVERT_DISABLE, /* Not inverted */
/* .invertShiftRegOutN = */CY_TCPWM_SHIFTREG_INVERT_DISABLE, /* Not inverted */
/* .reloadInputMode = */CY_TCPWM_INPUT_LEVEL, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_LEVEL) */
/* .reloadInput = */CY_TCPWM_INPUT_0,
/* .startInputMode = */CY_TCPWM_INPUT_LEVEL, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_LEVEL) */
/* .startInput = */CY_TCPWM_INPUT_0,
/* .killInputMode = */CY_TCPWM_INPUT_LEVEL, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_LEVEL) */
/* .killInput = */CY_TCPWM_INPUT_0,
/* .shiftInputMode = */CY_TCPWM_INPUT_LEVEL, /* Set this input to LEVEL and 1 (high logic level) */
/* .shiftInput = */CY_TCPWM_INPUT_1, /* Shift Register will run forever */
/* .serialInputMode = */CY_TCPWM_INPUT_LEVEL, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_LEVEL) */
/* .serialInput = */CY_TCPWM_INPUT_0,
/* .shiftRegOnDisable = */CY_TCPWM_SHIFTREG_OUTPUT_HIGHZ, /* Default High impedance mode*/
/* .trigger0Event = */CY_TCPWM_CNT_TRIGGER_ON_DISABLED, /* Disable output trigger0 event generation*/
/* .trigger1Event = */CY_TCPWM_CNT_TRIGGER_ON_DISABLED, /* Disable output trigger1 event generation*/
};
#define MY_TCPWM_SHIFTREG_NUM (0UL)
if (CY_TCPWM_SUCCESS != Cy_TCPWM_ShiftReg_Init(TCPWM0, MY_TCPWM_SHIFTREG_NUM, &shiftreg_config))
{
/* Handle possible errors */
}

Assign and Configure Pins

The dedicated TCPWM pins can be used. The HSIOM register must be configured to connect the block to the pins. Use the GPIO (General Purpose Input Output) driver API to do that.

/* Scenario:
* Configure P0[4] as Shift Register Line Output.
* Configure P0[5] as Shift Register Line Compliment Output.
*/
Cy_GPIO_Pin_FastInit(GPIO_PRT0, 4UL, CY_GPIO_DM_STRONG_IN_OFF, 0UL, P0_4_TCPWM0_LINE2);
Cy_GPIO_Pin_FastInit(GPIO_PRT0, 5UL, CY_GPIO_DM_STRONG_IN_OFF, 0UL, P0_5_TCPWM0_LINE_COMPL2);

Assign Clock Divider

The clock source must be connected for proper operation. Any of the peripheral clock dividers could be used. Use the SysClk (System Clock) driver API to do that.

Enable Shift Register

Shift Register has to be enabled before starting

/* Scenario: Enable Shift Register */
#define MY_TCPWM_SHIFTREG_NUM (0UL)
Cy_TCPWM_ShiftReg_Enable(TCPWM0, MY_TCPWM_SHIFTREG_NUM);

Start Shift Register

To start Shift Register operation Cy_TCPWM_TriggerStart_Single API can be used.

/* Scenario: Use software trigger to start Shift Register operation */
#define MY_TCPWM_SHIFTREG_NUM (0UL)
Cy_TCPWM_TriggerStart_Single(TCPWM0, MY_TCPWM_SHIFTREG_NUM);

API Reference

 Macros
 
 Functions
 
 Data Structures