MTB CAT1 Peripheral driver library

General Description

Functions

cy_en_tcpwm_status_t Cy_TCPWM_Counter_Init (TCPWM_Type *base, uint32_t cntNum, cy_stc_tcpwm_counter_config_t const *config)
 Initializes the counter in the TCPWM block for the Counter operation. More...
 
void Cy_TCPWM_Counter_DeInit (TCPWM_Type *base, uint32_t cntNum, cy_stc_tcpwm_counter_config_t const *config)
 De-initializes the counter in the TCPWM block, returns register values to default. More...
 
__STATIC_INLINE void Cy_TCPWM_Counter_Enable (TCPWM_Type *base, uint32_t cntNum)
 Enables the counter in the TCPWM block for the Counter operation. More...
 
__STATIC_INLINE void Cy_TCPWM_Counter_Disable (TCPWM_Type *base, uint32_t cntNum)
 Disables the counter in the TCPWM block. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetStatus (TCPWM_Type const *base, uint32_t cntNum)
 Returns the status of the Counter Timer whether it is running or not. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCapture0Val (TCPWM_Type const *base, uint32_t cntNum)
 Returns the capture 0 value when the capture mode is enabled. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCapture0BufVal (TCPWM_Type const *base, uint32_t cntNum)
 Returns the buffered capture 0 value when the capture mode is enabled. More...
 
__STATIC_INLINE void Cy_TCPWM_Counter_SetCompare0Val (TCPWM_Type *base, uint32_t cntNum, uint32_t compare0)
 Sets the compare value for Compare0 when the compare mode is enabled. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCompare0Val (TCPWM_Type const *base, uint32_t cntNum)
 Returns compare 0 value. More...
 
__STATIC_INLINE void Cy_TCPWM_Counter_SetCompare0BufVal (TCPWM_Type *base, uint32_t cntNum, uint32_t compare1)
 Sets the compare value for Compare1 when the compare mode is enabled. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCompare0BufVal (TCPWM_Type const *base, uint32_t cntNum)
 Returns the buffered compare 0 value. More...
 
__STATIC_INLINE void Cy_TCPWM_Counter_EnableCompare0Swap (TCPWM_Type *base, uint32_t cntNum, bool enable)
 Enables the comparison swap when the comparison value is true. More...
 
__STATIC_INLINE void Cy_TCPWM_Counter_SetCounter (TCPWM_Type *base, uint32_t cntNum, uint32_t count)
 Sets the value of the counter. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCounter (TCPWM_Type const *base, uint32_t cntNum)
 Returns the value in the counter. More...
 
__STATIC_INLINE void Cy_TCPWM_Counter_SetPeriod (TCPWM_Type *base, uint32_t cntNum, uint32_t period)
 Sets the value of the period register. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetPeriod (TCPWM_Type const *base, uint32_t cntNum)
 Returns the value in the period register. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCapture1Val (TCPWM_Type const *base, uint32_t cntNum)
 Returns capture 1 value when capture mode is enabled. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCapture1BufVal (TCPWM_Type const *base, uint32_t cntNum)
 Returns the buffered capture1 value when capture mode is enabled. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCompare1Val (TCPWM_Type const *base, uint32_t cntNum)
 Returns compare 1 value. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCompare1BufVal (TCPWM_Type const *base, uint32_t cntNum)
 Returns the buffered compare1 value. More...
 
__STATIC_INLINE void Cy_TCPWM_Counter_SetCompare1Val (TCPWM_Type *base, uint32_t cntNum, uint32_t compare1)
 Sets the compare value for Compare1 when the compare mode enabled. More...
 
__STATIC_INLINE void Cy_TCPWM_Counter_SetCompare1BufVal (TCPWM_Type *base, uint32_t cntNum, uint32_t compareBuf1)
 Sets the buffered compare value for Compare1 when the compare mode enabled. More...
 
__STATIC_INLINE void Cy_TCPWM_Counter_EnableCompare1Swap (TCPWM_Type *base, uint32_t cntNum, bool enable)
 Enables the comparison swap of compare1 and compareBuf1 when the comparison value is true. More...
 
__STATIC_INLINE void Cy_TCPWM_Counter_EnableSwap (TCPWM_Type *base, uint32_t cntNum, bool enable)
 Enables/disables swapping mechanism between CC0 and buffered CC0, CC1 and buffered CC1, PERIOD and buffered PERIOD, DT and buffered DT. More...
 
__STATIC_INLINE void Cy_TCPWM_Counter_SetDirection_Change_Mode (TCPWM_Type *base, uint32_t cntNum, cy_en_counter_direction_t direction_mode)
 Direction change mode Based on falling/rising edge of capture0 input. More...
 

Function Documentation

◆ Cy_TCPWM_Counter_Init()

cy_en_tcpwm_status_t Cy_TCPWM_Counter_Init ( TCPWM_Type base,
uint32_t  cntNum,
cy_stc_tcpwm_counter_config_t const *  config 
)

Initializes the counter in the TCPWM block for the Counter operation.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
configThe pointer to configuration structure. See cy_stc_tcpwm_counter_config_t.
Returns
error / status code. See cy_en_tcpwm_status_t.
Function Usage
/* Scenario: there is need to initialize
* the first (index = 0) counter of the TCPWM0 block
* with the below configuration settings
*/
cy_stc_tcpwm_counter_config_t tcpwm_v1_counter_config =
{
/* .period = */ 99UL, /* Period of 100 (0-99). Terminal count event when rolls over back to 0. */
/* .clockPrescaler = */ CY_TCPWM_COUNTER_PRESCALER_DIVBY_4, /* Clk_counter = Clk_input / 4 */
/* .runMode = */ CY_TCPWM_COUNTER_CONTINUOUS, /* Wrap around at terminal count. */
/* .countDirection = */ CY_TCPWM_COUNTER_COUNT_UP, /* Up counter, counting from 0 to period value. */
/* .compareOrCapture = */ CY_TCPWM_COUNTER_MODE_COMPARE, /* Trigger interrupt/event signal when Counter value is equal to Compare 0 */
/* .compare0 = */ 33UL,
/* .compare1 = */ 66UL,
/* .enableCompareSwap = */ true, /* Upon a compare event, swap the Compare 0 and Compare 1 values. */
/* .interruptSources = */ CY_TCPWM_INT_NONE,
/* .captureInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .captureInput = */ CY_TCPWM_INPUT_0,
/* .reloadInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .reloadInput = */ CY_TCPWM_INPUT_0,
/* .startInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .startInput = */ CY_TCPWM_INPUT_0,
/* .stopInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .stopInput = */ CY_TCPWM_INPUT_0,
/* .countInputMode = */ CY_TCPWM_INPUT_LEVEL, /* Set this input to LEVEL and 1 (high logic level) */
/* .countInput = */ CY_TCPWM_INPUT_1, /* So the counter will count input clock periods (Clk_counter, taking into account the clock prescaler) */
};
#define MY_TCPWM_CNT_NUM (0UL)
if (CY_TCPWM_SUCCESS != Cy_TCPWM_Counter_Init(TCPWM0, MY_TCPWM_CNT_NUM, &tcpwm_v1_counter_config))
{
/* Handle possible errors */
}
/* Enable the initialized counter */
Cy_TCPWM_Counter_Enable(TCPWM0, MY_TCPWM_CNT_NUM);
/* Then start the counter */
Cy_TCPWM_TriggerStart_Single(TCPWM0, MY_TCPWM_CNT_NUM);
/* Scenario: there is need to initialize
* the first (index = 0) counter of the TCPWM0 block
* with the below configuration settings
*/
cy_stc_tcpwm_counter_config_t tcpwm_v2_counter_config =
{
/* .period = */ 99UL, /* Period of 100 (0-99). Terminal count event when rolls over back to 0. */
/* .clockPrescaler = */ CY_TCPWM_COUNTER_PRESCALER_DIVBY_4, /* Clk_counter = Clk_input / 4 */
/* .runMode = */ CY_TCPWM_COUNTER_CONTINUOUS, /* Wrap around at terminal count. */
/* .countDirection = */ CY_TCPWM_COUNTER_COUNT_UP, /* Up counter, counting from 0 to period value. */
/* .compareOrCapture = */ CY_TCPWM_COUNTER_MODE_COMPARE, /* Trigger interrupt/event signal when Counter value is equal to Compare 0 */
/* .compare0 = */ 33UL,
/* .compare1 = */ 66UL,
/* .enableCompareSwap = */ true, /* Upon a compare event, swap the Compare 0 and Compare 1 values. */
/* .interruptSources = */ CY_TCPWM_INT_NONE,
/* .captureInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .captureInput = */ CY_TCPWM_INPUT_0,
/* .reloadInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .reloadInput = */ CY_TCPWM_INPUT_0,
/* .startInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .startInput = */ CY_TCPWM_INPUT_0,
/* .stopInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .stopInput = */ CY_TCPWM_INPUT_0,
/* .countInputMode = */ CY_TCPWM_INPUT_LEVEL, /* Set this input to LEVEL and 1 (high logic level) */
/* .countInput = */ CY_TCPWM_INPUT_1, /* So the counter will count input clock periods (Clk_counter, taking into account the clock prescaler) */
/* .capture1InputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .capture1Input = */ CY_TCPWM_INPUT_0,
/* .enableCompare1Swap= */ false, /* Disable CC1 */
/* .compare2 = */ 0,
/* .compare3 = */ 0,
/* .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_CNT_NUM (0UL)
if (CY_TCPWM_SUCCESS != Cy_TCPWM_Counter_Init(TCPWM0, MY_TCPWM_CNT_NUM, &tcpwm_v2_counter_config))
{
/* Handle possible errors */
}
/* Enable the initialized counter */
Cy_TCPWM_Counter_Enable(TCPWM0, MY_TCPWM_CNT_NUM);
/* Then start the counter */
Cy_TCPWM_TriggerStart_Single(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_Counter_DeInit()

void Cy_TCPWM_Counter_DeInit ( TCPWM_Type base,
uint32_t  cntNum,
cy_stc_tcpwm_counter_config_t const *  config 
)

De-initializes the counter in the TCPWM block, returns register values to default.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
configThe pointer to configuration structure. See cy_stc_tcpwm_counter_config_t.
Function Usage
/* Scenario: there is need to deinitialize the previously initialized counter */
#define MY_TCPWM_CNT_NUM (0UL)
/* Disable the counter prior to deinitializing */
Cy_TCPWM_Counter_Disable(TCPWM0, MY_TCPWM_CNT_NUM);
Cy_TCPWM_Counter_DeInit(TCPWM0, MY_TCPWM_CNT_NUM, &config);

◆ Cy_TCPWM_Counter_Enable()

__STATIC_INLINE void Cy_TCPWM_Counter_Enable ( TCPWM_Type base,
uint32_t  cntNum 
)

Enables the counter in the TCPWM block for the Counter operation.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Function Usage
/* Scenario: there is need to initialize
* the first (index = 0) counter of the TCPWM0 block
* with the below configuration settings
*/
cy_stc_tcpwm_counter_config_t tcpwm_v1_counter_config =
{
/* .period = */ 99UL, /* Period of 100 (0-99). Terminal count event when rolls over back to 0. */
/* .clockPrescaler = */ CY_TCPWM_COUNTER_PRESCALER_DIVBY_4, /* Clk_counter = Clk_input / 4 */
/* .runMode = */ CY_TCPWM_COUNTER_CONTINUOUS, /* Wrap around at terminal count. */
/* .countDirection = */ CY_TCPWM_COUNTER_COUNT_UP, /* Up counter, counting from 0 to period value. */
/* .compareOrCapture = */ CY_TCPWM_COUNTER_MODE_COMPARE, /* Trigger interrupt/event signal when Counter value is equal to Compare 0 */
/* .compare0 = */ 33UL,
/* .compare1 = */ 66UL,
/* .enableCompareSwap = */ true, /* Upon a compare event, swap the Compare 0 and Compare 1 values. */
/* .interruptSources = */ CY_TCPWM_INT_NONE,
/* .captureInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .captureInput = */ CY_TCPWM_INPUT_0,
/* .reloadInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .reloadInput = */ CY_TCPWM_INPUT_0,
/* .startInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .startInput = */ CY_TCPWM_INPUT_0,
/* .stopInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .stopInput = */ CY_TCPWM_INPUT_0,
/* .countInputMode = */ CY_TCPWM_INPUT_LEVEL, /* Set this input to LEVEL and 1 (high logic level) */
/* .countInput = */ CY_TCPWM_INPUT_1, /* So the counter will count input clock periods (Clk_counter, taking into account the clock prescaler) */
};
#define MY_TCPWM_CNT_NUM (0UL)
if (CY_TCPWM_SUCCESS != Cy_TCPWM_Counter_Init(TCPWM0, MY_TCPWM_CNT_NUM, &tcpwm_v1_counter_config))
{
/* Handle possible errors */
}
/* Enable the initialized counter */
Cy_TCPWM_Counter_Enable(TCPWM0, MY_TCPWM_CNT_NUM);
/* Then start the counter */
Cy_TCPWM_TriggerStart_Single(TCPWM0, MY_TCPWM_CNT_NUM);
/* Scenario: there is need to initialize
* the first (index = 0) counter of the TCPWM0 block
* with the below configuration settings
*/
cy_stc_tcpwm_counter_config_t tcpwm_v2_counter_config =
{
/* .period = */ 99UL, /* Period of 100 (0-99). Terminal count event when rolls over back to 0. */
/* .clockPrescaler = */ CY_TCPWM_COUNTER_PRESCALER_DIVBY_4, /* Clk_counter = Clk_input / 4 */
/* .runMode = */ CY_TCPWM_COUNTER_CONTINUOUS, /* Wrap around at terminal count. */
/* .countDirection = */ CY_TCPWM_COUNTER_COUNT_UP, /* Up counter, counting from 0 to period value. */
/* .compareOrCapture = */ CY_TCPWM_COUNTER_MODE_COMPARE, /* Trigger interrupt/event signal when Counter value is equal to Compare 0 */
/* .compare0 = */ 33UL,
/* .compare1 = */ 66UL,
/* .enableCompareSwap = */ true, /* Upon a compare event, swap the Compare 0 and Compare 1 values. */
/* .interruptSources = */ CY_TCPWM_INT_NONE,
/* .captureInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .captureInput = */ CY_TCPWM_INPUT_0,
/* .reloadInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .reloadInput = */ CY_TCPWM_INPUT_0,
/* .startInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .startInput = */ CY_TCPWM_INPUT_0,
/* .stopInputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .stopInput = */ CY_TCPWM_INPUT_0,
/* .countInputMode = */ CY_TCPWM_INPUT_LEVEL, /* Set this input to LEVEL and 1 (high logic level) */
/* .countInput = */ CY_TCPWM_INPUT_1, /* So the counter will count input clock periods (Clk_counter, taking into account the clock prescaler) */
/* .capture1InputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* This input is NOT used, leave it in default state (CY_TCPWM_INPUT_RISINGEDGE = 0UL) */
/* .capture1Input = */ CY_TCPWM_INPUT_0,
/* .enableCompare1Swap= */ false, /* Disable CC1 */
/* .compare2 = */ 0,
/* .compare3 = */ 0,
/* .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_CNT_NUM (0UL)
if (CY_TCPWM_SUCCESS != Cy_TCPWM_Counter_Init(TCPWM0, MY_TCPWM_CNT_NUM, &tcpwm_v2_counter_config))
{
/* Handle possible errors */
}
/* Enable the initialized counter */
Cy_TCPWM_Counter_Enable(TCPWM0, MY_TCPWM_CNT_NUM);
/* Then start the counter */
Cy_TCPWM_TriggerStart_Single(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_Counter_Disable()

__STATIC_INLINE void Cy_TCPWM_Counter_Disable ( TCPWM_Type base,
uint32_t  cntNum 
)

Disables the counter in the TCPWM block.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Function Usage
/* Scenario: there is need to deinitialize the previously initialized counter */
#define MY_TCPWM_CNT_NUM (0UL)
/* Disable the counter prior to deinitializing */
Cy_TCPWM_Counter_Disable(TCPWM0, MY_TCPWM_CNT_NUM);
Cy_TCPWM_Counter_DeInit(TCPWM0, MY_TCPWM_CNT_NUM, &config);

◆ Cy_TCPWM_Counter_GetStatus()

__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetStatus ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the status of the Counter Timer whether it is running or not.

In case the Counter is running, status will also provide information on counting up/down. This is useful when the counter mode is set to UP_DOWN_1 or UP_DOWN_2.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
The status. See Counter Status
Function Usage
/* Scenario: there is a need to check if
* the first (index = 0) counter of the TCPWM0 block is running or not.
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t status = Cy_TCPWM_Counter_GetStatus(TCPWM0, MY_TCPWM_CNT_NUM);
{
/* Up Counting */
}
{
/* Down Counting */
}
else
{
/* Counter is not running */
}

◆ Cy_TCPWM_Counter_GetCapture0Val()

__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCapture0Val ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the capture 0 value when the capture mode is enabled.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
The capture 0 value.
Function Usage
/* Scenario: there is a need to trigger software capture events for
* the first (index = 0) counter of the TCPWM0 block.
* Note: the counter should run in the Capture Mode.
*/
#define MY_TCPWM_CNT_NUM (0UL)
Cy_TCPWM_TriggerCaptureOrSwap_Single(TCPWM0, MY_TCPWM_CNT_NUM);
/* after some time */
Cy_TCPWM_TriggerCaptureOrSwap_Single(TCPWM0, MY_TCPWM_CNT_NUM);
/* Now we can get the latest captured value
* (captured during the second call of Cy_TCPWM_TriggerCaptureOrSwap_Single)
*/
uint32_t capture = Cy_TCPWM_Counter_GetCapture0Val(TCPWM0, MY_TCPWM_CNT_NUM);
/* Also the previous captured value
* (captured during the first call of Cy_TCPWM_TriggerCaptureOrSwap_Single)
* is available by the next way
*/
uint32_t captureBuf = Cy_TCPWM_Counter_GetCapture0BufVal(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_Counter_GetCapture0BufVal()

__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCapture0BufVal ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the buffered capture 0 value when the capture mode is enabled.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
The buffered capture 0 value.
Function Usage
/* Scenario: there is a need to trigger software capture events for
* the first (index = 0) counter of the TCPWM0 block.
* Note: the counter should run in the Capture Mode.
*/
#define MY_TCPWM_CNT_NUM (0UL)
Cy_TCPWM_TriggerCaptureOrSwap_Single(TCPWM0, MY_TCPWM_CNT_NUM);
/* after some time */
Cy_TCPWM_TriggerCaptureOrSwap_Single(TCPWM0, MY_TCPWM_CNT_NUM);
/* Now we can get the latest captured value
* (captured during the second call of Cy_TCPWM_TriggerCaptureOrSwap_Single)
*/
uint32_t capture = Cy_TCPWM_Counter_GetCapture0Val(TCPWM0, MY_TCPWM_CNT_NUM);
/* Also the previous captured value
* (captured during the first call of Cy_TCPWM_TriggerCaptureOrSwap_Single)
* is available by the next way
*/
uint32_t captureBuf = Cy_TCPWM_Counter_GetCapture0BufVal(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_Counter_SetCompare0Val()

__STATIC_INLINE void Cy_TCPWM_Counter_SetCompare0Val ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  compare0 
)

Sets the compare value for Compare0 when the compare mode is enabled.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
compare0The Compare0 value.
Function Usage
/* Scenario: there is a need to modify the Compare 0 value of
* the first (index = 0) counter of the TCPWM0 block.
* Note: the counter should run in the Compare Mode.
*/
#define MY_TCPWM_CNT_NUM (0UL)
/* Stop the counter for clear transition */
Cy_TCPWM_TriggerStopOrKill_Single(TCPWM0, MY_TCPWM_CNT_NUM);
/* Get the currently existing Compare 0 value */
uint32_t compare = Cy_TCPWM_Counter_GetCompare0Val(TCPWM0, MY_TCPWM_CNT_NUM);
/* Modify the compare value here */
Cy_TCPWM_Counter_SetCompare0Val(TCPWM0, MY_TCPWM_CNT_NUM, compare);
/* Restart the counter with the new Compare 0 value */
Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_Counter_GetCompare0Val()

__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCompare0Val ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns compare 0 value.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
Compare 0 value.
Function Usage
/* Scenario: there is a need to modify the Compare 0 value of
* the first (index = 0) counter of the TCPWM0 block.
* Note: the counter should run in the Compare Mode.
*/
#define MY_TCPWM_CNT_NUM (0UL)
/* Stop the counter for clear transition */
Cy_TCPWM_TriggerStopOrKill_Single(TCPWM0, MY_TCPWM_CNT_NUM);
/* Get the currently existing Compare 0 value */
uint32_t compare = Cy_TCPWM_Counter_GetCompare0Val(TCPWM0, MY_TCPWM_CNT_NUM);
/* Modify the compare value here */
Cy_TCPWM_Counter_SetCompare0Val(TCPWM0, MY_TCPWM_CNT_NUM, compare);
/* Restart the counter with the new Compare 0 value */
Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_Counter_SetCompare0BufVal()

__STATIC_INLINE void Cy_TCPWM_Counter_SetCompare0BufVal ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  compare1 
)

Sets the compare value for Compare1 when the compare mode is enabled.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
compare1The Compare1 value.
Function Usage
/* Scenario: there is a need to modify the alternative compare value
* (Compare 1) for the first (index = 0) counter of the TCPWM0 block.
* Note: the counter should run in the Compare Mode.
* Note: the compare swapping feature should be enabled.
*/
#define MY_TCPWM_CNT_NUM (0UL)
/* Get the currently existing Compare 1 value */
uint32_t compare = Cy_TCPWM_Counter_GetCompare0BufVal(TCPWM0, MY_TCPWM_CNT_NUM);
/* Modify the compare value here */
Cy_TCPWM_Counter_SetCompare0BufVal(TCPWM0, MY_TCPWM_CNT_NUM, compare);
/* Now the Compare 0 and Compare 1 values can be swapped using Cy_TCPWM_TriggerCaptureOrSwap_Single */

◆ Cy_TCPWM_Counter_GetCompare0BufVal()

__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCompare0BufVal ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the buffered compare 0 value.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
Buffered Compare 0 value.
Function Usage
/* Scenario: there is a need to modify the alternative compare value
* (Compare 1) for the first (index = 0) counter of the TCPWM0 block.
* Note: the counter should run in the Compare Mode.
* Note: the compare swapping feature should be enabled.
*/
#define MY_TCPWM_CNT_NUM (0UL)
/* Get the currently existing Compare 1 value */
uint32_t compare = Cy_TCPWM_Counter_GetCompare0BufVal(TCPWM0, MY_TCPWM_CNT_NUM);
/* Modify the compare value here */
Cy_TCPWM_Counter_SetCompare0BufVal(TCPWM0, MY_TCPWM_CNT_NUM, compare);
/* Now the Compare 0 and Compare 1 values can be swapped using Cy_TCPWM_TriggerCaptureOrSwap_Single */

◆ Cy_TCPWM_Counter_EnableCompare0Swap()

__STATIC_INLINE void Cy_TCPWM_Counter_EnableCompare0Swap ( TCPWM_Type base,
uint32_t  cntNum,
bool  enable 
)

Enables the comparison swap when the comparison value is true.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
enabletrue = swap enabled, false = swap disabled
Function Usage
/* Scenario: there is a need to enable the compare swapping feature for
* the first (index = 0) counter of the TCPWM0 block.
*/
#define MY_TCPWM_CNT_NUM (0UL)
Cy_TCPWM_Counter_EnableCompare0Swap(TCPWM0, MY_TCPWM_CNT_NUM, true);
/* Now the Compare 0 and Compare 1 values can be swapped using Cy_TCPWM_TriggerCaptureOrSwap_Single */
Note
From Version 3 of TCPWM, this feature is coupled with the swap enable feature (Cy_TCPWM_Counter_EnableSwap()). when both reload and swap are enabled then CC0 value is swapped with CC0 buff value. When only reload is enabled then CC0 buff value is copied to CC0. There is no action when reload is disabled.

◆ Cy_TCPWM_Counter_SetCounter()

__STATIC_INLINE void Cy_TCPWM_Counter_SetCounter ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  count 
)

Sets the value of the counter.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
countThe value to write into the counter.
Function Usage
/* Scenario: there is a need to set the counter value for
* the first (index = 0) counter of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
#define MY_TCPWM_CNT_VAL (100UL)
Cy_TCPWM_TriggerStopOrKill_Single(TCPWM0, MY_TCPWM_CNT_NUM);
Cy_TCPWM_Counter_SetCounter(TCPWM0, MY_TCPWM_CNT_NUM, MY_TCPWM_CNT_VAL);
Cy_TCPWM_TriggerStart_Single(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_Counter_GetCounter()

__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCounter ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the value in the counter.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
The current counter value.
Function Usage
/* Scenario: there is a need to get the current counter value of
* the first (index = 0) counter of the TCPWM0 block
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t count = Cy_TCPWM_Counter_GetCounter(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_Counter_SetPeriod()

__STATIC_INLINE void Cy_TCPWM_Counter_SetPeriod ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  period 
)

Sets the value of the period register.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
periodThe value to write into a period.
Function Usage
/* Scenario: there is a need to modify the period of
* the first (index = 0) counter of the TCPWM0 block.
*/
#define MY_TCPWM_CNT_NUM (0UL)
/* Get the currently existing period value */
uint32_t period = Cy_TCPWM_Counter_GetPeriod(TCPWM0, MY_TCPWM_CNT_NUM);
/* Modify the period value here */
Cy_TCPWM_Counter_SetPeriod(TCPWM0, MY_TCPWM_CNT_NUM, period);

◆ Cy_TCPWM_Counter_GetPeriod()

__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetPeriod ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the value in the period register.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
The current period value.
Function Usage
/* Scenario: there is a need to modify the period of
* the first (index = 0) counter of the TCPWM0 block.
*/
#define MY_TCPWM_CNT_NUM (0UL)
/* Get the currently existing period value */
uint32_t period = Cy_TCPWM_Counter_GetPeriod(TCPWM0, MY_TCPWM_CNT_NUM);
/* Modify the period value here */
Cy_TCPWM_Counter_SetPeriod(TCPWM0, MY_TCPWM_CNT_NUM, period);

◆ Cy_TCPWM_Counter_GetCapture1Val()

__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCapture1Val ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns capture 1 value when capture mode is enabled.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
Capture 1 value.

◆ Cy_TCPWM_Counter_GetCapture1BufVal()

__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCapture1BufVal ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the buffered capture1 value when capture mode is enabled.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
Buffered capture1 value.

◆ Cy_TCPWM_Counter_GetCompare1Val()

__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCompare1Val ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns compare 1 value.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
Compare 1 value.
Function Usage
/* Scenario: there is a need to modify the alternative compare value
* (Compare 1) for the first (index = 256) counter of Group 1 of the TCPWM0 block.
* Note: the counter should run in the Compare Mode.
* Note: the compare swapping feature should be enabled.
*/
#define MY_TCPWM_GRP1_CNT0_NUM (256UL)
/* Get the currently existing Compare 1 value and set a new Compare 1 Val */
uint32_t compare1 = Cy_TCPWM_Counter_GetCompare1Val(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM);
/* Modify the compare value here */
Cy_TCPWM_Counter_SetCompare1Val(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM, compare1);
/* Get the currently existing Compare1Buf value and set a new Compare1Buf Val */
uint32_t compareBuf1 = Cy_TCPWM_Counter_GetCompare1BufVal(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM);
/* Modify the compare1Buff value here */
Cy_TCPWM_Counter_SetCompare1BufVal(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM, compareBuf1);

◆ Cy_TCPWM_Counter_GetCompare1BufVal()

__STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCompare1BufVal ( TCPWM_Type const *  base,
uint32_t  cntNum 
)

Returns the buffered compare1 value.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
Buffered compare1 value.
Function Usage
/* Scenario: there is a need to modify the alternative compare value
* (Compare 1) for the first (index = 256) counter of Group 1 of the TCPWM0 block.
* Note: the counter should run in the Compare Mode.
* Note: the compare swapping feature should be enabled.
*/
#define MY_TCPWM_GRP1_CNT0_NUM (256UL)
/* Get the currently existing Compare 1 value and set a new Compare 1 Val */
uint32_t compare1 = Cy_TCPWM_Counter_GetCompare1Val(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM);
/* Modify the compare value here */
Cy_TCPWM_Counter_SetCompare1Val(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM, compare1);
/* Get the currently existing Compare1Buf value and set a new Compare1Buf Val */
uint32_t compareBuf1 = Cy_TCPWM_Counter_GetCompare1BufVal(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM);
/* Modify the compare1Buff value here */
Cy_TCPWM_Counter_SetCompare1BufVal(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM, compareBuf1);

◆ Cy_TCPWM_Counter_SetCompare1Val()

__STATIC_INLINE void Cy_TCPWM_Counter_SetCompare1Val ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  compare1 
)

Sets the compare value for Compare1 when the compare mode enabled.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
compare1The Compare1 value.
Function Usage
/* Scenario: there is a need to modify the alternative compare value
* (Compare 1) for the first (index = 256) counter of Group 1 of the TCPWM0 block.
* Note: the counter should run in the Compare Mode.
* Note: the compare swapping feature should be enabled.
*/
#define MY_TCPWM_GRP1_CNT0_NUM (256UL)
/* Get the currently existing Compare 1 value and set a new Compare 1 Val */
uint32_t compare1 = Cy_TCPWM_Counter_GetCompare1Val(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM);
/* Modify the compare value here */
Cy_TCPWM_Counter_SetCompare1Val(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM, compare1);
/* Get the currently existing Compare1Buf value and set a new Compare1Buf Val */
uint32_t compareBuf1 = Cy_TCPWM_Counter_GetCompare1BufVal(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM);
/* Modify the compare1Buff value here */
Cy_TCPWM_Counter_SetCompare1BufVal(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM, compareBuf1);

◆ Cy_TCPWM_Counter_SetCompare1BufVal()

__STATIC_INLINE void Cy_TCPWM_Counter_SetCompare1BufVal ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  compareBuf1 
)

Sets the buffered compare value for Compare1 when the compare mode enabled.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
compareBuf1The buffered Compare1 value.
Function Usage
/* Scenario: there is a need to modify the alternative compare value
* (Compare 1) for the first (index = 256) counter of Group 1 of the TCPWM0 block.
* Note: the counter should run in the Compare Mode.
* Note: the compare swapping feature should be enabled.
*/
#define MY_TCPWM_GRP1_CNT0_NUM (256UL)
/* Get the currently existing Compare 1 value and set a new Compare 1 Val */
uint32_t compare1 = Cy_TCPWM_Counter_GetCompare1Val(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM);
/* Modify the compare value here */
Cy_TCPWM_Counter_SetCompare1Val(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM, compare1);
/* Get the currently existing Compare1Buf value and set a new Compare1Buf Val */
uint32_t compareBuf1 = Cy_TCPWM_Counter_GetCompare1BufVal(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM);
/* Modify the compare1Buff value here */
Cy_TCPWM_Counter_SetCompare1BufVal(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM, compareBuf1);

◆ Cy_TCPWM_Counter_EnableCompare1Swap()

__STATIC_INLINE void Cy_TCPWM_Counter_EnableCompare1Swap ( TCPWM_Type base,
uint32_t  cntNum,
bool  enable 
)

Enables the comparison swap of compare1 and compareBuf1 when the comparison value is true.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
enabletrue = swap enabled; false = swap disabled
Function Usage
/* Scenario: there is a need to enable the compare swapping feature for
* the first (index = 256) counter of Group 1 of TCPWM0 block.
*/
#define MY_TCPWM_GRP1_CNT0_NUM (256UL)
Cy_TCPWM_Counter_EnableCompare1Swap(TCPWM0, MY_TCPWM_GRP1_CNT0_NUM, true);
/* Now the Compare1Val and Compare1BufVal values can be swapped using Cy_TCPWM_TriggerCapture1 */
Note
From Version 3 of TCPWM, this feature is coupled with the swap enable feature (Cy_TCPWM_Counter_EnableSwap()). when both reload and swap are enabled then CC1 value is swapped with CC1 buff value. When only reload is enabled then CC1 buff value is copied to CC1. There is no action when reload is disabled.

◆ Cy_TCPWM_Counter_EnableSwap()

__STATIC_INLINE void Cy_TCPWM_Counter_EnableSwap ( TCPWM_Type base,
uint32_t  cntNum,
bool  enable 
)

Enables/disables swapping mechanism between CC0 and buffered CC0, CC1 and buffered CC1, PERIOD and buffered PERIOD, DT and buffered DT.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
enabletrue = swap enabled; false = swap disabled
Note
This feature is coupled with the reload feature. when both reload and swap are enabled then CC0/CC1/PERIOD/DT values are swapped with CC_BUFF/CC1_BUFF/PERIOD_BUFF/DT_BUFF values respectively When only reload is enabled then CC_BUFF/CC1_BUFF/PERIOD_BUFF/DT_BUFF values are copied to CC0/CC1/PERIOD/DT respectively. There is no action when reload is disabled.

◆ Cy_TCPWM_Counter_SetDirection_Change_Mode()

__STATIC_INLINE void Cy_TCPWM_Counter_SetDirection_Change_Mode ( TCPWM_Type base,
uint32_t  cntNum,
cy_en_counter_direction_t  direction_mode 
)

Direction change mode Based on falling/rising edge of capture0 input.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
direction_modeDirection change mode Based on falling/rising edge of capture0 input cy_en_counter_direction_t
Note
For TCPWM version 3 and above in compare mode, when external direction control is enabled and Capture0 input is disabled, user can use software capture0 trigger. While using this, User has to make sure that the external direction control is set to CY_TCPWM_COUNTER_DIRECTION_RISING