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:
- 16- or 32-bit Counter
- 2 compare (CC0/CC1) registers with double buffer.
- Programmable Counter taps through PERIOD_BUFF register.
- Line output generated from a XOR combination of all enabled counter taps (bit position) defined by PERIOD_BUFF.
- Programmable Compare Register. Compare value can be swapped with a buffered compare value on comparison event.
- Interrupt on Comparison match events (CC0_MATCH/CC1_MATCH).
- Start, Reload, Stop, Shift, and Serial-in Inputs.
- Comparison match and Line Outputs.
- Line output can be output with invert polarity.
- 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.
{
0x80000000UL,
16384UL,
16384UL,
false,
16384UL,
16384UL,
false,
};
#define MY_TCPWM_SHIFTREG_NUM (0UL)
{
}
Shift Register configuration structure.
Definition: cy_tcpwm_shiftreg.h:121
@ CY_TCPWM_SUCCESS
Successful.
Definition: cy_tcpwm.h:402
cy_en_tcpwm_status_t Cy_TCPWM_ShiftReg_Init(TCPWM_Type const *base, uint32_t cntNum, cy_stc_tcpwm_shiftreg_config_t const *config)
Initializes the counter in the TCPWM block for the Shift Register operation.
Definition: cy_tcpwm_shiftreg.c:55
#define CY_TCPWM_INT_ON_CC0
Interrupt on Compare 0/Capture 0(CC0)
Definition: cy_tcpwm.h:307
#define CY_TCPWM_CNT_TRIGGER_ON_DISABLED
Output trigger disabled.
Definition: cy_tcpwm.h:297
#define CY_TCPWM_SHIFTREG_PRESCALER_DIVBY_1
Divide by 1.
Definition: cy_tcpwm_shiftreg.h:166
#define CY_TCPWM_SHIFTREG_INVERT_DISABLE
Do not invert the output mode.
Definition: cy_tcpwm_shiftreg.h:189
#define CY_TCPWM_SHIFTREG_OUTPUT_HIGHZ
Shift Register output (default) high impedance.
Definition: cy_tcpwm_shiftreg.h:197
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.
#define CY_GPIO_DM_STRONG_IN_OFF
Strong Drive.
Definition: cy_gpio.h:514
void Cy_GPIO_Pin_FastInit(GPIO_PRT_Type *base, uint32_t pinNum, uint32_t driveMode, uint32_t outVal, en_hsiom_sel_t hsiom)
Initialize the most common configuration settings for all pin types.
Definition: cy_gpio.c:419
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
#define MY_TCPWM_SHIFTREG_NUM (0UL)
__STATIC_INLINE void Cy_TCPWM_ShiftReg_Enable(TCPWM_Type *base, uint32_t cntNum)
Enables the counter in the TCPWM block for the Shift Register operation.
Definition: cy_tcpwm_shiftreg.h:273
Start Shift Register
To start Shift Register operation Cy_TCPWM_TriggerStart_Single API can be used.
#define MY_TCPWM_SHIFTREG_NUM (0UL)
__STATIC_INLINE void Cy_TCPWM_TriggerStart_Single(TCPWM_Type *base, uint32_t cntNum)
Triggers a software start on the selected TCPWM.
Definition: cy_tcpwm.h:891