Functions

group group_tcpwm_functions_quaddec

Functions

cy_en_tcpwm_status_t Cy_TCPWM_QuadDec_Init(TCPWM_Type *base, uint32_t cntNum, cy_stc_tcpwm_quaddec_config_t const *config)

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

Return

error / status code. See cy_en_tcpwm_status_t.

Function Usage

    /* Scenario: there is need to initialize
     * the first (index = 0) quadrature decoder of the TCPWM0 block
     * with the below configuration settings
     */
    cy_stc_tcpwm_quaddec_config_t tcpwm_v1_qd_config =
    {
        /* .resolution        = */ CY_TCPWM_QUADDEC_X1, /* One count during one encoder cycle */
        /* .interruptSources  = */ CY_TCPWM_INT_ON_TC,  /* Simple example without index input */
        /* .indexInputMode    = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
        /* .indexInput        = */ CY_TCPWM_INPUT_0, /* The index input is not used */
        /* .stopInputMode     = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
        /* .stopInput         = */ CY_TCPWM_INPUT_0, /* The stop input is not used, the block will be stopped by SW */
        /* .phiAInput         = */ CY_TCPWM_INPUT_TRIG_0, /* The phiA input is connected to the trigger multiplexer #0 of the Trigger Group #3 */
        /* .phiBInput         = */ CY_TCPWM_INPUT_TRIG_1,  /* The phiB input is connected to the trigger multiplexer #1 of the Trigger Group #3 */
    };

    #define MY_TCPWM_CNT_NUM   (0UL)

    if (CY_TCPWM_SUCCESS != Cy_TCPWM_QuadDec_Init(TCPWM0, MY_TCPWM_CNT_NUM, &tcpwm_v1_qd_config))
    {
        /* Handle possible errors */
    }
    /* Enabled the initialized quadrature decoder */
    Cy_TCPWM_QuadDec_Enable(TCPWM0, MY_TCPWM_CNT_NUM);

    /* Then start the decoder */
    Cy_TCPWM_TriggerStart_Single(TCPWM0, MY_TCPWM_CNT_NUM);
    /* Scenario: there is need to initialize
     * the first (index = 0) quadrature decoder of the TCPWM0 block
     * with the below configuration settings
     */
    cy_stc_tcpwm_quaddec_config_t tcpwm_v2_qd_config =
    {
        /* .resolution        = */ CY_TCPWM_QUADDEC_X1, /* One count during one encoder cycle */
        /* .interruptSources  = */ CY_TCPWM_INT_ON_TC,  /* Simple example without index input */
        /* .indexInputMode    = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
        /* .indexInput        = */ CY_TCPWM_INPUT_0, /* The index input is not used */
        /* .stopInputMode     = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
        /* .stopInput         = */ CY_TCPWM_INPUT_0, /* The stop input is not used, the block will be stopped by SW */
        /* .phiAInput         = */ CY_TCPWM_INPUT_TRIG_0, /* The phiA input is connected to the trigger multiplexer #0 of the Trigger Group #3 */
        /* .phiBInput         = */ CY_TCPWM_INPUT_TRIG_1,  /* The phiB input is connected to the trigger multiplexer #1 of the Trigger Group #3 */
        /* .phiAInputMode     = */ CY_TCPWM_INPUT_LEVEL, /* Pass thorugh (no edge detection) */
        /* .phiBInputMode     = */ CY_TCPWM_INPUT_LEVEL, /* Pass thorugh (no edge detection) */
        /* .quadmode          = */ CY_TCPWM_QUADDEC_MODE_RANGE0, /* Quad mode */
        /* .period0           = */ 0UL, /* Period 0 Value */
        /* .captureOnIndex    = */ CY_TCPWM_QUADDEC_CAPTURE_ON_INDEX, /* Capture On Index event */
        /* .compare0          = */ 0Ul, /* Sets the value for Compare 0 */
        /* .compareBuf0       = */ 0UL, /* Sets the value for the buffered Compare 0 */
        /* .enableCompare0Swap = */ false, /*  If enabled, the compare 0 values are swapped on the terminal count */
        /* .compare1          = */ 0UL, /* Sets the value for Compare 1 */
        /* .compareBuf1       = */ 0UL, /* Sets the value for the buffered Compare 0 */
        /* .enableCompare1Swap = */ false, /*  If enabled, the compare 0 values are swapped on the terminal count */
        /* .capture0OrIndex1InputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* Configures how the capture0/index1 input behaves.*/
        /* .capture0OrIndex1Input = */ CY_TCPWM_INPUT_0, /* Selects which input the capture0/index1 uses. The inputs are device-specific. */
        /* .capture1InputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* Configures how the capture1 input behaves. */
        /* .capture1Input     = */ CY_TCPWM_INPUT_0, /* Selects which input the capture1 uses. The inputs are device-specific. */
        /* .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_QuadDec_Init(TCPWM0, MY_TCPWM_CNT_NUM, &tcpwm_v2_qd_config))
    {
        /* Handle possible errors */
    }
    /* Enabled the initialized quadrature decoder */
    Cy_TCPWM_QuadDec_Enable(TCPWM0, MY_TCPWM_CNT_NUM);
    
    /* Then start the decoder */
    Cy_TCPWM_TriggerStart_Single(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

  • config: The pointer to a configuration structure. See cy_stc_tcpwm_quaddec_config_t.

void Cy_TCPWM_QuadDec_DeInit(TCPWM_Type *base, uint32_t cntNum, cy_stc_tcpwm_quaddec_config_t const *config)

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

Function Usage

    /* Scenario: there is need to deinitialize the previously initialized block */
    #define MY_TCPWM_CNT_NUM   (0UL)
    
    /* Disable the counter prior to deinitializing */
    Cy_TCPWM_QuadDec_Disable(TCPWM0, MY_TCPWM_CNT_NUM);
    Cy_TCPWM_QuadDec_DeInit(TCPWM0, MY_TCPWM_CNT_NUM, &config);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

  • config: The pointer to a configuration structure. See cy_stc_tcpwm_quaddec_config_t.

__STATIC_INLINE void Cy_TCPWM_QuadDec_Enable (TCPWM_Type *base, uint32_t cntNum)

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

Function Usage

    /* Scenario: there is need to initialize
     * the first (index = 0) quadrature decoder of the TCPWM0 block
     * with the below configuration settings
     */
    cy_stc_tcpwm_quaddec_config_t tcpwm_v1_qd_config =
    {
        /* .resolution        = */ CY_TCPWM_QUADDEC_X1, /* One count during one encoder cycle */
        /* .interruptSources  = */ CY_TCPWM_INT_ON_TC,  /* Simple example without index input */
        /* .indexInputMode    = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
        /* .indexInput        = */ CY_TCPWM_INPUT_0, /* The index input is not used */
        /* .stopInputMode     = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
        /* .stopInput         = */ CY_TCPWM_INPUT_0, /* The stop input is not used, the block will be stopped by SW */
        /* .phiAInput         = */ CY_TCPWM_INPUT_TRIG_0, /* The phiA input is connected to the trigger multiplexer #0 of the Trigger Group #3 */
        /* .phiBInput         = */ CY_TCPWM_INPUT_TRIG_1,  /* The phiB input is connected to the trigger multiplexer #1 of the Trigger Group #3 */
    };

    #define MY_TCPWM_CNT_NUM   (0UL)

    if (CY_TCPWM_SUCCESS != Cy_TCPWM_QuadDec_Init(TCPWM0, MY_TCPWM_CNT_NUM, &tcpwm_v1_qd_config))
    {
        /* Handle possible errors */
    }
    /* Enabled the initialized quadrature decoder */
    Cy_TCPWM_QuadDec_Enable(TCPWM0, MY_TCPWM_CNT_NUM);

    /* Then start the decoder */
    Cy_TCPWM_TriggerStart_Single(TCPWM0, MY_TCPWM_CNT_NUM);
    /* Scenario: there is need to initialize
     * the first (index = 0) quadrature decoder of the TCPWM0 block
     * with the below configuration settings
     */
    cy_stc_tcpwm_quaddec_config_t tcpwm_v2_qd_config =
    {
        /* .resolution        = */ CY_TCPWM_QUADDEC_X1, /* One count during one encoder cycle */
        /* .interruptSources  = */ CY_TCPWM_INT_ON_TC,  /* Simple example without index input */
        /* .indexInputMode    = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
        /* .indexInput        = */ CY_TCPWM_INPUT_0, /* The index input is not used */
        /* .stopInputMode     = */ CY_TCPWM_INPUT_RISINGEDGE, /* The default value (0UL) */
        /* .stopInput         = */ CY_TCPWM_INPUT_0, /* The stop input is not used, the block will be stopped by SW */
        /* .phiAInput         = */ CY_TCPWM_INPUT_TRIG_0, /* The phiA input is connected to the trigger multiplexer #0 of the Trigger Group #3 */
        /* .phiBInput         = */ CY_TCPWM_INPUT_TRIG_1,  /* The phiB input is connected to the trigger multiplexer #1 of the Trigger Group #3 */
        /* .phiAInputMode     = */ CY_TCPWM_INPUT_LEVEL, /* Pass thorugh (no edge detection) */
        /* .phiBInputMode     = */ CY_TCPWM_INPUT_LEVEL, /* Pass thorugh (no edge detection) */
        /* .quadmode          = */ CY_TCPWM_QUADDEC_MODE_RANGE0, /* Quad mode */
        /* .period0           = */ 0UL, /* Period 0 Value */
        /* .captureOnIndex    = */ CY_TCPWM_QUADDEC_CAPTURE_ON_INDEX, /* Capture On Index event */
        /* .compare0          = */ 0Ul, /* Sets the value for Compare 0 */
        /* .compareBuf0       = */ 0UL, /* Sets the value for the buffered Compare 0 */
        /* .enableCompare0Swap = */ false, /*  If enabled, the compare 0 values are swapped on the terminal count */
        /* .compare1          = */ 0UL, /* Sets the value for Compare 1 */
        /* .compareBuf1       = */ 0UL, /* Sets the value for the buffered Compare 0 */
        /* .enableCompare1Swap = */ false, /*  If enabled, the compare 0 values are swapped on the terminal count */
        /* .capture0OrIndex1InputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* Configures how the capture0/index1 input behaves.*/
        /* .capture0OrIndex1Input = */ CY_TCPWM_INPUT_0, /* Selects which input the capture0/index1 uses. The inputs are device-specific. */
        /* .capture1InputMode = */ CY_TCPWM_INPUT_RISINGEDGE, /* Configures how the capture1 input behaves. */
        /* .capture1Input     = */ CY_TCPWM_INPUT_0, /* Selects which input the capture1 uses. The inputs are device-specific. */
        /* .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_QuadDec_Init(TCPWM0, MY_TCPWM_CNT_NUM, &tcpwm_v2_qd_config))
    {
        /* Handle possible errors */
    }
    /* Enabled the initialized quadrature decoder */
    Cy_TCPWM_QuadDec_Enable(TCPWM0, MY_TCPWM_CNT_NUM);
    
    /* Then start the decoder */
    Cy_TCPWM_TriggerStart_Single(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

__STATIC_INLINE void Cy_TCPWM_QuadDec_Disable (TCPWM_Type *base, uint32_t cntNum)

Disables the counter in the TCPWM block.

Function Usage

    /* Scenario: there is need to deinitialize the previously initialized block */
    #define MY_TCPWM_CNT_NUM   (0UL)
    
    /* Disable the counter prior to deinitializing */
    Cy_TCPWM_QuadDec_Disable(TCPWM0, MY_TCPWM_CNT_NUM);
    Cy_TCPWM_QuadDec_DeInit(TCPWM0, MY_TCPWM_CNT_NUM, &config);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

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

Returns the status of the QuadDec whether it is running or not.

In case the QuadDec is running, status will also provide information on counting up/down.

Return

The status. See QuadDec Status

Function Usage

    /* Scenario: there is a need to check if
     * the first (index = 0) quadrature decoder of the TCPWM0 block is running or not.
     */
    #define MY_TCPWM_CNT_NUM   (0UL)
    
    uint32_t status = Cy_TCPWM_QuadDec_GetStatus(TCPWM0, MY_TCPWM_CNT_NUM);

    if ((CY_TCPWM_QUADDEC_STATUS_COUNTER_RUNNING & status) && (CY_TCPWM_QUADDEC_STATUS_UP_COUNTING & status))
    {
        /* Up Counting */
    }
    else if ((CY_TCPWM_QUADDEC_STATUS_COUNTER_RUNNING & status) && (CY_TCPWM_QUADDEC_STATUS_DOWN_COUNTING & status))
    {
        /* Down Counting */
    }
    else
    {
        /* QuadDec is not running */
    }

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

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

Returns the capture value.

Return

The capture value.

Function Usage

    /* Scenario: there is a need to get the capture values of
     * the first (index = 0) quadrature decoder of the TCPWM0 block.
     */
    #define MY_TCPWM_CNT_NUM   (0UL)
    
    /* The capture event can be triggered either by the Index HW input
     * or by software:
     */
    Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);
    /* after some time or encoder moving */
    Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);
    
    /* Now we can get the latest captured value 
     * (captured during the second call of Cy_TCPWM_TriggerReloadOrIndex_Single)
     */
    uint32_t capture = Cy_TCPWM_QuadDec_GetCapture0Val(TCPWM0, MY_TCPWM_CNT_NUM);
    /* Also the previous captured value
     * (captured during the first call of Cy_TCPWM_TriggerReloadOrIndex_Single)
     * is available by the next way
     */
    uint32_t captureBuf = Cy_TCPWM_QuadDec_GetCapture0BufVal(TCPWM0, MY_TCPWM_CNT_NUM);
    

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

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

Returns the buffered capture value.

Return

The buffered capture value.

Function Usage

    /* Scenario: there is a need to get the capture values of
     * the first (index = 0) quadrature decoder of the TCPWM0 block.
     */
    #define MY_TCPWM_CNT_NUM   (0UL)
    
    /* The capture event can be triggered either by the Index HW input
     * or by software:
     */
    Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);
    /* after some time or encoder moving */
    Cy_TCPWM_TriggerReloadOrIndex_Single(TCPWM0, MY_TCPWM_CNT_NUM);
    
    /* Now we can get the latest captured value 
     * (captured during the second call of Cy_TCPWM_TriggerReloadOrIndex_Single)
     */
    uint32_t capture = Cy_TCPWM_QuadDec_GetCapture0Val(TCPWM0, MY_TCPWM_CNT_NUM);
    /* Also the previous captured value
     * (captured during the first call of Cy_TCPWM_TriggerReloadOrIndex_Single)
     * is available by the next way
     */
    uint32_t captureBuf = Cy_TCPWM_QuadDec_GetCapture0BufVal(TCPWM0, MY_TCPWM_CNT_NUM);
    

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCompare0Val (TCPWM_Type *base, uint32_t cntNum, uint32_t compare0)

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

Function Usage

    /* Scenario: there is a need to set compare 0 value
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    uint32_t compare0 = 0uL;

    Cy_TCPWM_QuadDec_SetCompare0Val(TCPWM0, MY_TCPWM_CNT_NUM, 255U);

    compare0 = Cy_TCPWM_QuadDec_GetCompare0Val(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

  • compare0: The Compare 0 value.

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

Returns compare 0 value.

Return

Compare 0 value.

Function Usage

    /* Scenario: there is a need to set compare 0 value
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    uint32_t compare0 = 0uL;

    Cy_TCPWM_QuadDec_SetCompare0Val(TCPWM0, MY_TCPWM_CNT_NUM, 255U);

    compare0 = Cy_TCPWM_QuadDec_GetCompare0Val(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCompare0BufVal (TCPWM_Type *base, uint32_t cntNum, uint32_t compareBuf0)

Sets the Buffered Compare 0 value when the compare mode is enabled.

Function Usage

    /* Scenario: there is a need to set buffered compare 0 value
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    uint32_t compare0buff = 0uL;

    Cy_TCPWM_QuadDec_SetCompare0BufVal(TCPWM0, MY_TCPWM_CNT_NUM, 255U);

    compare0buff = Cy_TCPWM_QuadDec_GetCompare0BufVal(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

  • compareBuf0: The Buffered Compare 0 value.

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

Returns Buffered Compare 0 Value.

Return

Buffered Compare 0 Value.

Function Usage

    /* Scenario: there is a need to set buffered compare 0 value
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    uint32_t compare0buff = 0uL;

    Cy_TCPWM_QuadDec_SetCompare0BufVal(TCPWM0, MY_TCPWM_CNT_NUM, 255U);

    compare0buff = Cy_TCPWM_QuadDec_GetCompare0BufVal(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

__STATIC_INLINE void Cy_TCPWM_QuadDec_EnableCompare0Swap (TCPWM_Type *base, uint32_t cntNum, bool enable)

Enables the comparison swap of compare 0 and compareBuf 0 when the comparision value is true.

Function Usage

    /* Scenario: there is a need to swap compare 0 and compare 0 buffer values
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    Cy_TCPWM_QuadDec_EnableCompare0Swap(TCPWM0, MY_TCPWM_CNT_NUM, 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

__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCounter (TCPWM_Type *base, uint32_t cntNum, uint32_t count)

Sets the value of 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   (0x8000UL) /* The "neutral" position for 16-bit decoder */
    
    Cy_TCPWM_TriggerStopOrKill_Single(TCPWM0, MY_TCPWM_CNT_NUM);
    Cy_TCPWM_QuadDec_SetCounter(TCPWM0, MY_TCPWM_CNT_NUM, MY_TCPWM_CNT_VAL);
    Cy_TCPWM_TriggerStart_Single(TCPWM0, MY_TCPWM_CNT_NUM);

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.

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

Returns the value in the counter.

Return

The current counter value.

Function Usage

    /* Scenario: there is a need to get the current counter value
     * (i.e. essentially the current position of the quadrature encoder)
     * of the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    uint32_t count = Cy_TCPWM_QuadDec_GetCounter(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

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

Returns capture 1 value when capture mode is enabled.

Return

Capture 1 value.

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

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

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

Return

Buffered capture 1 value.

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

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

Returns compare 1 value.

Return

Compare 1 value.

Function Usage

    /* Scenario: there is a need to set compare 1 value
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    uint32_t compare1 = 0uL;

    Cy_TCPWM_QuadDec_SetCompare1Val(TCPWM0, MY_TCPWM_CNT_NUM, 255U);

    compare1 = Cy_TCPWM_QuadDec_GetCompare1Val(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

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

Returns the buffered compare 1 value.

Return

Buffered compare 1 value.

Function Usage

    /* Scenario: there is a need to set compare 1 buffer value
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    uint32_t compare1buff = 0uL;

    Cy_TCPWM_QuadDec_SetCompare1BufVal(TCPWM0, MY_TCPWM_CNT_NUM, 255U);

    compare1buff = Cy_TCPWM_QuadDec_GetCompare1BufVal(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCompare1Val (TCPWM_Type *base, uint32_t cntNum, uint32_t compare1)

Sets the compare value for Compare 1 when the compare mode enabled.

Function Usage

    /* Scenario: there is a need to set compare 1 value
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    uint32_t compare1 = 0uL;

    Cy_TCPWM_QuadDec_SetCompare1Val(TCPWM0, MY_TCPWM_CNT_NUM, 255U);

    compare1 = Cy_TCPWM_QuadDec_GetCompare1Val(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

  • compare1: The Compare 1 value.

__STATIC_INLINE void Cy_TCPWM_QuadDec_SetCompare1BufVal (TCPWM_Type *base, uint32_t cntNum, uint32_t compareBuf1)

Sets the buffered compare value for Compare 1 when the compare mode enabled.

Function Usage

    /* Scenario: there is a need to set compare 1 buffer value
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    uint32_t compare1buff = 0uL;

    Cy_TCPWM_QuadDec_SetCompare1BufVal(TCPWM0, MY_TCPWM_CNT_NUM, 255U);

    compare1buff = Cy_TCPWM_QuadDec_GetCompare1BufVal(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

  • compareBuf1: The buffered Compare 1 value.

__STATIC_INLINE void Cy_TCPWM_QuadDec_EnableCompare1Swap (TCPWM_Type *base, uint32_t cntNum, bool enable)

Enables the comparison swap of compare 1 and compareBuf 1 when the comparision value is true.

Function Usage

    /* Scenario: there is a need to swap compare 1 and compare 1 buffer values
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    Cy_TCPWM_QuadDec_EnableCompare1Swap(TCPWM0, MY_TCPWM_CNT_NUM, 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

__STATIC_INLINE void Cy_TCPWM_QuadDec_SetPeriod0 (TCPWM_Type *base, uint32_t cntNum, uint32_t period0)

Sets the value of the period register.

Function Usage

    /* Scenario: there is a need to set period 0 value
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    uint32_t period0 = 0uL;

    Cy_TCPWM_QuadDec_SetPeriod0(TCPWM0, MY_TCPWM_CNT_NUM, 255U);

    period0 = Cy_TCPWM_QuadDec_GetPeriod0(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

  • period0: The value to write into a period.

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

Returns the value in the period 0 register.

Return

The current period value.

Function Usage

    /* Scenario: there is a need to set period 0 value
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    uint32_t period0 = 0uL;

    Cy_TCPWM_QuadDec_SetPeriod0(TCPWM0, MY_TCPWM_CNT_NUM, 255U);

    period0 = Cy_TCPWM_QuadDec_GetPeriod0(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

__STATIC_INLINE void Cy_TCPWM_QuadDec_SetPeriod1 (TCPWM_Type *base, uint32_t cntNum, uint32_t period1)

Sets the value of the period register.

note

supported only in TCPWM_ver2

Function Usage

    /* Scenario: there is a need to set period 1 value
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    uint32_t period1 = 0uL;

    Cy_TCPWM_QuadDec_SetPeriod1(TCPWM0, MY_TCPWM_CNT_NUM, 255U);

    period1 = Cy_TCPWM_QuadDec_GetPeriod1(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

  • period1: The value to write into a period 1.

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

Returns the value in the period 1 register.

note

supported only in TCPWM_ver2

Return

The current period 1 value.

Function Usage

    /* Scenario: there is a need to set period 1 value
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    uint32_t period1 = 0uL;

    Cy_TCPWM_QuadDec_SetPeriod1(TCPWM0, MY_TCPWM_CNT_NUM, 255U);

    period1 = Cy_TCPWM_QuadDec_GetPeriod1(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.

__STATIC_INLINE void Cy_TCPWM_QuadDec_TriggerIndex1 (TCPWM_Type *base, uint32_t cntNum)

Triggers a software index 1.

Function Usage

    /* Scenario: there is a need to trigger Index1 event
      * for the first (index = 0) quadrature decoder of the TCPWM0 block
     */
    #define MY_TCPWM_CNT_NUM   (0UL)

    Cy_TCPWM_QuadDec_TriggerIndex1(TCPWM0, MY_TCPWM_CNT_NUM);

Parameters
  • base: The pointer to a TCPWM instance.

  • cntNum: The Counter instance number in the selected TCPWM.