PSOC E8XXGP Device Support Library

| PSOC E8XXGP Device Support Library

Functions
Functions
PDL API Reference » TCPWM (Timer Counter PWM) » Timer/Counter (TCPWM)

## 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

  base | The pointer to a TCPWM instance.
  cntNum | The Counter instance number in the selected TCPWM.
  config | The 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);
  CY_TCPWM_COUNTER_PRESCALER_DIVBY_4
  #define CY_TCPWM_COUNTER_PRESCALER_DIVBY_4
  Divide by 4.
  Definition: cy_tcpwm_counter.h:215
  CY_TCPWM_COUNTER_MODE_COMPARE
  #define CY_TCPWM_COUNTER_MODE_COMPARE
  Timer/Counter is in Compare Mode.
  Definition: cy_tcpwm_counter.h:228
  CY_TCPWM_COUNTER_COUNT_UP
  #define CY_TCPWM_COUNTER_COUNT_UP
  Counter counts up.
  Definition: cy_tcpwm_counter.h:201
  CY_TCPWM_COUNTER_CONTINUOUS
  #define CY_TCPWM_COUNTER_CONTINUOUS
  Counter runs forever.
  Definition: cy_tcpwm_counter.h:194
  cy_stc_tcpwm_counter_config_t
  Counter Timer configuration structure.
  Definition: cy_tcpwm_counter.h:140
  CY_TCPWM_SUCCESS
  @ CY_TCPWM_SUCCESS
  Successful.
  Definition: cy_tcpwm.h:402
  Cy_TCPWM_TriggerStart_Single
  __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
  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.
  Definition: cy_tcpwm_counter.h:316
  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.
  Definition: cy_tcpwm_counter.c:58
  CY_TCPWM_INPUT_RISINGEDGE
  #define CY_TCPWM_INPUT_RISINGEDGE
  A rising edge triggers the event (Capture, Start, Reload, etc..)
  Definition: cy_tcpwm.h:266
  CY_TCPWM_INPUT_LEVEL
  #define CY_TCPWM_INPUT_LEVEL
  The event is triggered on each edge of the TCPWM clock if the input is high.
  Definition: cy_tcpwm.h:272
  CY_TCPWM_INPUT_1
  #define CY_TCPWM_INPUT_1
  Input is tied to logic 1.
  Definition: cy_tcpwm.h:229
  CY_TCPWM_INPUT_0
  #define CY_TCPWM_INPUT_0
  Input is tied to logic 0.
  Definition: cy_tcpwm.h:228
  CY_TCPWM_INT_NONE
  #define CY_TCPWM_INT_NONE
  No Interrupt.
  Definition: cy_tcpwm.h:305
  /* 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_CNT_TRIGGER_ON_DISABLED
  #define CY_TCPWM_CNT_TRIGGER_ON_DISABLED
  Output trigger disabled.
  Definition: cy_tcpwm.h:297

## ◆ 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

  base | The pointer to a TCPWM instance.
  cntNum | The Counter instance number in the selected TCPWM.
  config | The 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_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.
  Definition: cy_tcpwm_counter.c:234
  Cy_TCPWM_Counter_Disable
  __STATIC_INLINE void Cy_TCPWM_Counter_Disable(TCPWM_Type *base, uint32_t cntNum)
  Disables the counter in the TCPWM block.
  Definition: cy_tcpwm_counter.h:338

## ◆ 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

  base | The pointer to a TCPWM instance.
  cntNum | The 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

  base | The pointer to a TCPWM instance.
  cntNum | The 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

  base | The pointer to a TCPWM instance.
  cntNum | The Counter instance number in the selected TCPWM.

Returns
  The status. See Counter Status

Note
  The status value is not the same as in TCPWM status register.

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);
  if ((CY_TCPWM_COUNTER_STATUS_COUNTER_RUNNING & status) && (CY_TCPWM_COUNTER_STATUS_UP_COUNTING & status))
  {
  /* Up Counting */
  }
  else if ((CY_TCPWM_COUNTER_STATUS_COUNTER_RUNNING & status) && (CY_TCPWM_COUNTER_STATUS_DOWN_COUNTING & status))
  {
  /* Down Counting */
  }
  else
  {
  /* Counter is not running */
  }
  CY_TCPWM_COUNTER_STATUS_UP_COUNTING
  #define CY_TCPWM_COUNTER_STATUS_UP_COUNTING
  Timer/Counter is up counting.
  Definition: cy_tcpwm_counter.h:236
  CY_TCPWM_COUNTER_STATUS_DOWN_COUNTING
  #define CY_TCPWM_COUNTER_STATUS_DOWN_COUNTING
  Timer/Counter is down counting.
  Definition: cy_tcpwm_counter.h:235
  CY_TCPWM_COUNTER_STATUS_COUNTER_RUNNING
  #define CY_TCPWM_COUNTER_STATUS_COUNTER_RUNNING
  Timer/Counter is running.
  Definition: cy_tcpwm_counter.h:242
  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.
  Definition: cy_tcpwm_counter.h:367

## ◆ 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

  base | The pointer to a TCPWM instance.
  cntNum | The 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_TriggerCaptureOrSwap_Single
  __STATIC_INLINE void Cy_TCPWM_TriggerCaptureOrSwap_Single(TCPWM_Type *base, uint32_t cntNum)
  Triggers a Capture 0 in the Timer Counter mode, and a Swap in the PWM mode on selected TCPWM.
  Definition: cy_tcpwm.h:973
  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.
  Definition: cy_tcpwm_counter.h:427
  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.
  Definition: cy_tcpwm_counter.h:452

## ◆ 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

  base | The pointer to a TCPWM instance.
  cntNum | The 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

  base | The pointer to a TCPWM instance.
  cntNum | The Counter instance number in the selected TCPWM.
  compare0 | The 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_TriggerReloadOrIndex_Single
  __STATIC_INLINE void Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM_Type *base, uint32_t cntNum)
  Triggers a software reload event (or index 0 in QuadDec mode) on selected TCPWM.
  Definition: cy_tcpwm.h:916
  Cy_TCPWM_TriggerStopOrKill_Single
  __STATIC_INLINE void Cy_TCPWM_TriggerStopOrKill_Single(TCPWM_Type *base, uint32_t cntNum)
  Triggers a stop in the Timer Counter mode, or a kill in the PWM mode on selected TCPWM.
  Definition: cy_tcpwm.h:947
  Cy_TCPWM_Counter_GetCompare0Val
  __STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCompare0Val(TCPWM_Type const *base, uint32_t cntNum)
  Returns compare 0 value.
  Definition: cy_tcpwm_counter.h:502
  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.
  Definition: cy_tcpwm_counter.h:477

## ◆ Cy_TCPWM_Counter_GetCompare0Val()

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

Returns compare 0 value.

Parameters

  base | The pointer to a TCPWM instance.
  cntNum | The 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

  base | The pointer to a TCPWM instance.
  cntNum | The Counter instance number in the selected TCPWM.
  compare1 | The 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.
  Definition: cy_tcpwm_counter.h:552
  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.
  Definition: cy_tcpwm_counter.h:527

## ◆ 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

  base | The pointer to a TCPWM instance.
  cntNum | The 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

  base | The pointer to a TCPWM instance.
  cntNum | The Counter instance number in the selected TCPWM.
  enable | true = 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 */
  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.
  Definition: cy_tcpwm_counter.h:582

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

  base | The pointer to a TCPWM instance.
  cntNum | The Counter instance number in the selected TCPWM.
  count | The 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_SetCounter
  __STATIC_INLINE void Cy_TCPWM_Counter_SetCounter(TCPWM_Type *base, uint32_t cntNum, uint32_t count)
  Sets the value of the counter.
  Definition: cy_tcpwm_counter.h:607

## ◆ 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

  base | The pointer to a TCPWM instance.
  cntNum | The 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_GetCounter
  __STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCounter(TCPWM_Type const *base, uint32_t cntNum)
  Returns the value in the counter.
  Definition: cy_tcpwm_counter.h:632

## ◆ 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

  base | The pointer to a TCPWM instance.
  cntNum | The Counter instance number in the selected TCPWM.
  period | The 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_SetPeriod
  __STATIC_INLINE void Cy_TCPWM_Counter_SetPeriod(TCPWM_Type *base, uint32_t cntNum, uint32_t period)
  Sets the value of the period register.
  Definition: cy_tcpwm_counter.h:657
  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.
  Definition: cy_tcpwm_counter.h:682

## ◆ 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

  base | The pointer to a TCPWM instance.
  cntNum | The 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

  base | The pointer to a TCPWM instance.
  cntNum | The 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

  base | The pointer to a TCPWM instance.
  cntNum | The 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

  base | The pointer to a TCPWM instance.
  cntNum | The 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_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.
  Definition: cy_tcpwm_counter.h:757
  Cy_TCPWM_Counter_GetCompare1BufVal
  __STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCompare1BufVal(TCPWM_Type const *base, uint32_t cntNum)
  Returns the buffered compare1 value.
  Definition: cy_tcpwm_counter.h:782
  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.
  Definition: cy_tcpwm_counter.h:707
  Cy_TCPWM_Counter_GetCompare1Val
  __STATIC_INLINE uint32_t Cy_TCPWM_Counter_GetCompare1Val(TCPWM_Type const *base, uint32_t cntNum)
  Returns compare 1 value.
  Definition: cy_tcpwm_counter.h:732

## ◆ 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

  base | The pointer to a TCPWM instance.
  cntNum | The 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

  base | The pointer to a TCPWM instance.
  cntNum | The Counter instance number in the selected TCPWM.
  compare1 | The 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

  base | The pointer to a TCPWM instance.
  cntNum | The Counter instance number in the selected TCPWM.
  compareBuf1 | The 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

  base | The pointer to a TCPWM instance.
  cntNum | The Counter instance number in the selected TCPWM.
  enable | true = 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 */
  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.
  Definition: cy_tcpwm_counter.h:854

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

  base | The pointer to a TCPWM instance.
  cntNum | The Counter instance number in the selected TCPWM.
  enable | true = 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

  base | The pointer to a TCPWM instance.
  cntNum | The Counter instance number in the selected TCPWM.
  direction_mode | Direction 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