PSoC 6 Peripheral Driver Library

General Description

Functions

__STATIC_INLINE void Cy_Profile_Init (void)
 Initializes and enables the profile hardware. More...
 
__STATIC_INLINE void Cy_Profile_DeInit (void)
 Clears the interrupt mask and disables the profile hardware. More...
 
void Cy_Profile_StartProfiling (void)
 Starts the profiling/measurement window. More...
 
__STATIC_INLINE void Cy_Profile_StopProfiling (void)
 Stops the profiling/measurement window. More...
 
__STATIC_INLINE uint32_t Cy_Profile_IsProfiling (void)
 Reports the active status of the profiling window. More...
 

Function Documentation

◆ Cy_Profile_Init()

__STATIC_INLINE void Cy_Profile_Init ( void  )

Initializes and enables the profile hardware.

This function must be called once when energy profiling is desired. The operation does not start a profiling session.

Note
The profile interrupt must also be configured. Cy_Profile_ISR() can be used as its handler.
Function Usage
/* Scenario: The Energy Profiler block needs to be initialized before
configuring the profile counters. The profile interrupt is
configured using the sysint driver. Its handler function
is Cy_Profile_ISR(). It is enabled using NVIC_EnableIRQ(). */
/* Initialize the energy profiler */
/* Clear all counter configurations */

◆ Cy_Profile_DeInit()

__STATIC_INLINE void Cy_Profile_DeInit ( void  )

Clears the interrupt mask and disables the profile hardware.

This function should be called when energy profiling is no longer desired.

Note
The profile interrupt is not disabled by this operation and must be disabled separately.
Function Usage
/* Scenario: The energy profiler is no longer required and needs to be
turned off. All profile counters are disabled. The profile
interrupt is also disabled using NVIC_DisableIRQ(). */
/* Stop profiling */
/* Turn off the energy profiler */

◆ Cy_Profile_StartProfiling()

void Cy_Profile_StartProfiling ( void  )

Starts the profiling/measurement window.

This operation allows the enabled profile counters to start counting.

Note
The profile interrupt should be enabled before calling this function for the firmware to be notified when a counter overflow occurs.
Function Usage
/* Scenario: The CM0 activity needs to be monitored during a fixed
window. The profile interrupt is configured using the sysint
driver. Its handler function is Cy_Profile_ISR(). The interrupt
is enabled using NVIC_EnableIRQ(). */
/* List of handles for allocated counters */
cy_stc_profile_ctr_ptr_t cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};
/* Initialize the energy profiler */
/* Configure a profile counter to monitor the CM0 activity and enable it */
cntHandle[0] = Cy_Profile_ConfigureCounter(CPUSS_MONITOR_CM0, /* CM0 active cycles count */
CY_PROFILE_EVENT, /* Count number of active cycles */
CY_PROFILE_CLK_TIMER, /* Ignored for "event" counting */
10UL); /* Weight of 10 (example) */
/* Enable the assigned counter */
(void)Cy_Profile_EnableCounter(cntHandle[0]);
/* Start the profiling window. */
/* When ready to read the result, stop the profiling window */

◆ Cy_Profile_StopProfiling()

__STATIC_INLINE void Cy_Profile_StopProfiling ( void  )

Stops the profiling/measurement window.

This operation prevents the enabled profile counters from counting.

Note
The profile interrupt should be disabled before calling this function.
Function Usage
/* Scenario: The weighted average of all the counter values in the profiling
window needs to be read. The energy profiler and the profile
interrupt are initialized and enabled. The profile counters
are configured and enabled. */
/* List of handles for allocated counters */
cy_stc_profile_ctr_ptr_t cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};
/* Start the profiling window */
/* Perform some activity... */
/* When ready to read the results of the counter values, stop the profiling window. */
/* Energy limit (example) of a profiling window */
uint64_t energyLimit = 0x00100000UL;
/* Get the weighted average of all the counter values */
uint64_t weightedAvg = Cy_Profile_GetSumWeightedCounts(cntHandle, PROFILE_PRFL_CNT_NR);
if(weightedAvg > energyLimit)
{
/* The energy consumption is more than expected for this profiling window.
Take appropriate measures to reduce the energy consumption. */
}

◆ Cy_Profile_IsProfiling()

__STATIC_INLINE uint32_t Cy_Profile_IsProfiling ( void  )

Reports the active status of the profiling window.

Returns
0 = profiling is not active; 1 = profiling is active
Function Usage
/* Scenario: The status of the profiling window needs to be known to make
a determination as to whether to start a profiling window
or to stop it. */
{
/* Stop the profiling window */
}
else
{
/* Start the profiling window */
}