PSoC 6 Peripheral Driver Library

General Description

Functions

__STATIC_INLINE void Cy_TCPWM_Enable_Multiple (TCPWM_Type *base, uint32_t counters)
 Enables the counter(s) in the TCPWM block. More...
 
__STATIC_INLINE void Cy_TCPWM_Disable_Multiple (TCPWM_Type *base, uint32_t counters)
 Disables the counter(s) in the TCPWM block. More...
 
__STATIC_INLINE void Cy_TCPWM_TriggerStart (TCPWM_Type *base, uint32_t counters)
 Triggers a software start on the selected TCPWMs. More...
 
__STATIC_INLINE void Cy_TCPWM_TriggerReloadOrIndex (TCPWM_Type *base, uint32_t counters)
 Triggers a software reload event (or index in QuadDec mode). More...
 
__STATIC_INLINE void Cy_TCPWM_TriggerStopOrKill (TCPWM_Type *base, uint32_t counters)
 Triggers a stop in the Timer Counter mode, or a kill in the PWM mode. More...
 
__STATIC_INLINE void Cy_TCPWM_TriggerCaptureOrSwap (TCPWM_Type *base, uint32_t counters)
 Triggers a Capture in the Timer Counter mode, and a Swap in the PWM mode. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_GetInterruptStatus (TCPWM_Type const *base, uint32_t cntNum)
 Returns which event triggered the interrupt. More...
 
__STATIC_INLINE void Cy_TCPWM_ClearInterrupt (TCPWM_Type *base, uint32_t cntNum, uint32_t source)
 Clears Active Interrupt Source. More...
 
__STATIC_INLINE void Cy_TCPWM_SetInterrupt (TCPWM_Type *base, uint32_t cntNum, uint32_t source)
 Triggers an interrupt via a software write. More...
 
__STATIC_INLINE void Cy_TCPWM_SetInterruptMask (TCPWM_Type *base, uint32_t cntNum, uint32_t mask)
 Sets an interrupt mask. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_GetInterruptMask (TCPWM_Type const *base, uint32_t cntNum)
 Returns the interrupt mask. More...
 
__STATIC_INLINE uint32_t Cy_TCPWM_GetInterruptStatusMasked (TCPWM_Type const *base, uint32_t cntNum)
 Returns which masked interrupt triggered the interrupt. More...
 

Function Documentation

◆ Cy_TCPWM_Enable_Multiple()

__STATIC_INLINE void Cy_TCPWM_Enable_Multiple ( TCPWM_Type base,
uint32_t  counters 
)

Enables the counter(s) in the TCPWM block.

Multiple blocks can be started simultaneously.

Parameters
baseThe pointer to a TCPWM instance.
countersA bit field representing each counter in the TCPWM block.
Function Usage
/* Scenario: there is a need to enable counters #1, #5 and #6 in the TCPWM0
* block.
* Multiple counters will be enabled simultaneously using
* MY_TCPWM_CNT_MULT_MASK (multiple bit masks ORed together).
*/
#define MY_TCPWM_CNT_1 (1UL)
#define MY_TCPWM_CNT_5 (5UL)
#define MY_TCPWM_CNT_6 (6UL)
#define MY_TCPWM_CNT_MULT_MASK (uint32_t)((1UL << MY_TCPWM_CNT_1) |\
(1UL << MY_TCPWM_CNT_5) |\
(1UL << MY_TCPWM_CNT_6))
Cy_TCPWM_Enable_Multiple(TCPWM0, MY_TCPWM_CNT_MULT_MASK);
/* Scenario: These counters are configured to generate signals that have a phase
* dependency to each other. These must all be enabled at the same time
* to preserve this phase relationship.
*/
Cy_TCPWM_TriggerStart(TCPWM0, MY_TCPWM_CNT_MULT_MASK);

◆ Cy_TCPWM_Disable_Multiple()

__STATIC_INLINE void Cy_TCPWM_Disable_Multiple ( TCPWM_Type base,
uint32_t  counters 
)

Disables the counter(s) in the TCPWM block.

Multiple TCPWM can be disabled simultaneously.

Parameters
baseThe pointer to a TCPWM instance.
countersA bit field representing each counter in the TCPWM block.
Function Usage
/* Scenario: there is a need to disable counters #1, #5 and #6 in the TCPWM0
* block.
*/
#define MY_TCPWM_CNT_1 (1UL)
#define MY_TCPWM_CNT_5 (5UL)
#define MY_TCPWM_CNT_6 (6UL)
#define MY_TCPWM_CNT_MULT_MASK (uint32_t)((1UL << MY_TCPWM_CNT_1) |\
(1UL << MY_TCPWM_CNT_5) |\
(1UL << MY_TCPWM_CNT_6))
Cy_TCPWM_Disable_Multiple(TCPWM0, MY_TCPWM_CNT_MULT_MASK);

◆ Cy_TCPWM_TriggerStart()

__STATIC_INLINE void Cy_TCPWM_TriggerStart ( TCPWM_Type base,
uint32_t  counters 
)

Triggers a software start on the selected TCPWMs.

Parameters
baseThe pointer to a TCPWM instance.
countersA bit field representing each counter in the TCPWM block.
Function Usage
/* Scenario: there is a need to enable counters #1, #5 and #6 in the TCPWM0
* block.
* Multiple counters will be enabled simultaneously using
* MY_TCPWM_CNT_MULT_MASK (multiple bit masks ORed together).
*/
#define MY_TCPWM_CNT_1 (1UL)
#define MY_TCPWM_CNT_5 (5UL)
#define MY_TCPWM_CNT_6 (6UL)
#define MY_TCPWM_CNT_MULT_MASK (uint32_t)((1UL << MY_TCPWM_CNT_1) |\
(1UL << MY_TCPWM_CNT_5) |\
(1UL << MY_TCPWM_CNT_6))
Cy_TCPWM_Enable_Multiple(TCPWM0, MY_TCPWM_CNT_MULT_MASK);
/* Scenario: These counters are configured to generate signals that have a phase
* dependency to each other. These must all be enabled at the same time
* to preserve this phase relationship.
*/
Cy_TCPWM_TriggerStart(TCPWM0, MY_TCPWM_CNT_MULT_MASK);

◆ Cy_TCPWM_TriggerReloadOrIndex()

__STATIC_INLINE void Cy_TCPWM_TriggerReloadOrIndex ( TCPWM_Type base,
uint32_t  counters 
)

Triggers a software reload event (or index in QuadDec mode).

Parameters
baseThe pointer to a TCPWM instance
countersA bit field representing each counter in the TCPWM block.
Function Usage
/* Scenario: there is a need to trigger a software reload event for
* the first (index = 0) counter of the TCPWM0 block.
* This causes the reloading of the counter register with the period value.
*/
#define MY_TCPWM_CNT_NUM (0UL)
#define MY_TCPWM_CNT_MASK (1UL << MY_TCPWM_CNT_NUM)
Cy_TCPWM_TriggerReloadOrIndex(TCPWM0, MY_TCPWM_CNT_MASK);

◆ Cy_TCPWM_TriggerStopOrKill()

__STATIC_INLINE void Cy_TCPWM_TriggerStopOrKill ( TCPWM_Type base,
uint32_t  counters 
)

Triggers a stop in the Timer Counter mode, or a kill in the PWM mode.

Parameters
baseThe pointer to a TCPWM instance.
countersA bit field representing each counter in the TCPWM block.
Function Usage
/* Scenario: there is a need to kill 3 PWM signals
* (PWM runs in \ref CY_TCPWM_PWM_STOP_ON_KILL mode) at the same time
* as they are all used e.g. to drive an RGB LED. So there will be a clean
* transition from white light to no light.
*/
#define MY_TCPWM_CNT_1 (1UL)
#define MY_TCPWM_CNT_5 (5UL)
#define MY_TCPWM_CNT_6 (6UL)
#define MY_TCPWM_CNT_MULT_MASK (uint32_t)((1UL << MY_TCPWM_CNT_1) |\
(1UL << MY_TCPWM_CNT_5) |\
(1UL << MY_TCPWM_CNT_6))
Cy_TCPWM_TriggerStopOrKill(TCPWM0, MY_TCPWM_CNT_MULT_MASK);
/* Then continue to operate from the point they have been stopped. */
Cy_TCPWM_TriggerStart(TCPWM0, MY_TCPWM_CNT_MULT_MASK);

◆ Cy_TCPWM_TriggerCaptureOrSwap()

__STATIC_INLINE void Cy_TCPWM_TriggerCaptureOrSwap ( TCPWM_Type base,
uint32_t  counters 
)

Triggers a Capture in the Timer Counter mode, and a Swap in the PWM mode.

Parameters
baseThe pointer to a TCPWM instance.
countersA bit field representing each counter in the TCPWM block.
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)
#define MY_TCPWM_CNT_MASK (1UL << MY_TCPWM_CNT_NUM)
Cy_TCPWM_TriggerCaptureOrSwap(TCPWM0, MY_TCPWM_CNT_MASK);
/* after some time */
Cy_TCPWM_TriggerCaptureOrSwap(TCPWM0, MY_TCPWM_CNT_MASK);
/* Now we can get the latest captured value
* (captured during the second call of Cy_TCPWM_TriggerCaptureOrSwap)
*/
uint32_t capture = Cy_TCPWM_Counter_GetCapture(TCPWM0, MY_TCPWM_CNT_NUM);
/* Also the previous captured value
* (captured during the first call of Cy_TCPWM_TriggerCaptureOrSwap)
* is available by the next way
*/
uint32_t captureBuf = Cy_TCPWM_Counter_GetCaptureBuf(TCPWM0, MY_TCPWM_CNT_NUM);

◆ Cy_TCPWM_GetInterruptStatus()

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

Returns which event triggered the interrupt.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
See Interrupt Sources
Function Usage
/* Scenario: there is a need to check all the pending interrupts of
* the first (index = 0) counter of the TCPWM0 block.
*/
#define MY_TCPWM_CNT_NUM (0UL)
uint32_t interrupts = Cy_TCPWM_GetInterruptStatus(TCPWM0, MY_TCPWM_CNT_NUM);
/* Now the 'interrupts' contains all the currently pending interrupt masks */
if(0UL != (CY_TCPWM_INT_ON_TC & interrupts))
{
/* There is a pending Terminal Count interrupt */
}

◆ Cy_TCPWM_ClearInterrupt()

__STATIC_INLINE void Cy_TCPWM_ClearInterrupt ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  source 
)

Clears Active Interrupt Source.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
sourcesource to clear. See Interrupt Sources
Function Usage
/* Scenario: inside the TCPWM interrupt handler for
* the first (index = 0) counter of the TCPWM0 block.
*/
#define MY_TCPWM_CNT_NUM (0UL)
/* Get all the enabled pending interrupts */
uint32_t interrupts = Cy_TCPWM_GetInterruptStatusMasked(TCPWM0, MY_TCPWM_CNT_NUM);
if (0UL != (CY_TCPWM_INT_ON_TC & interrupts))
{
/* Handle the Terminal Count event */
}
if (0UL != (CY_TCPWM_INT_ON_CC & interrupts))
{
/* Handle the Compare/Capture event */
}
/* Clear the interrupt */
Cy_TCPWM_ClearInterrupt(TCPWM0, MY_TCPWM_CNT_NUM, interrupts);

◆ Cy_TCPWM_SetInterrupt()

__STATIC_INLINE void Cy_TCPWM_SetInterrupt ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  source 
)

Triggers an interrupt via a software write.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
sourceThe source to set an interrupt. See Interrupt Sources.
Function Usage
/* Scenario: there is a need to set a terminal count interrupt by SW for
* the first (index = 0) counter of the TCPWM0 block.
*/
#define MY_TCPWM_CNT_NUM (0UL)
/* Check if the desired interrupt is enabled prior to triggering */
if (0UL != (CY_TCPWM_INT_ON_TC & Cy_TCPWM_GetInterruptMask(TCPWM0, MY_TCPWM_CNT_NUM)))
{
Cy_TCPWM_SetInterrupt(TCPWM0, MY_TCPWM_CNT_NUM, CY_TCPWM_INT_ON_TC);
}
else
{
/* The terminal count interrupt is not enabled, so there is no sense to trigger it */
}

◆ Cy_TCPWM_SetInterruptMask()

__STATIC_INLINE void Cy_TCPWM_SetInterruptMask ( TCPWM_Type base,
uint32_t  cntNum,
uint32_t  mask 
)

Sets an interrupt mask.

A 1 means that when the event occurs, it will cause an interrupt; a 0 means no interrupt will be triggered.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
mask. See Interrupt Sources
Function Usage
/* Scenario: there is a need to set the Compare/Capture interrupt mask for
* the first (index = 0) counter of the TCPWM0 block.
*/
#define MY_TCPWM_CNT_NUM (0UL)
Cy_TCPWM_SetInterruptMask(TCPWM0, MY_TCPWM_CNT_NUM,
CY_TCPWM_INT_ON_CC | Cy_TCPWM_GetInterruptMask(TCPWM0, MY_TCPWM_CNT_NUM));

◆ Cy_TCPWM_GetInterruptMask()

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

Returns the interrupt mask.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
Interrupt Mask. See Interrupt Sources
Function Usage
/* Scenario: there is a need to set the Compare/Capture interrupt mask for
* the first (index = 0) counter of the TCPWM0 block.
*/
#define MY_TCPWM_CNT_NUM (0UL)
Cy_TCPWM_SetInterruptMask(TCPWM0, MY_TCPWM_CNT_NUM,
CY_TCPWM_INT_ON_CC | Cy_TCPWM_GetInterruptMask(TCPWM0, MY_TCPWM_CNT_NUM));

◆ Cy_TCPWM_GetInterruptStatusMasked()

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

Returns which masked interrupt triggered the interrupt.

Parameters
baseThe pointer to a TCPWM instance.
cntNumThe Counter instance number in the selected TCPWM.
Returns
Interrupt Mask. See Interrupt Sources
Function Usage
/* Scenario: inside the TCPWM interrupt handler for
* the first (index = 0) counter of the TCPWM0 block.
*/
#define MY_TCPWM_CNT_NUM (0UL)
/* Get all the enabled pending interrupts */
uint32_t interrupts = Cy_TCPWM_GetInterruptStatusMasked(TCPWM0, MY_TCPWM_CNT_NUM);
if (0UL != (CY_TCPWM_INT_ON_TC & interrupts))
{
/* Handle the Terminal Count event */
}
if (0UL != (CY_TCPWM_INT_ON_CC & interrupts))
{
/* Handle the Compare/Capture event */
}
/* Clear the interrupt */
Cy_TCPWM_ClearInterrupt(TCPWM0, MY_TCPWM_CNT_NUM, interrupts);