MTB CAT1 Peripheral driver library
Calculation Functions

General Description

Functions

cy_en_profile_status_t Cy_Profile_GetRawCount (cy_stc_profile_ctr_ptr_t ctrAddr, uint64_t *result)
 Reports the raw count value for a specified counter. More...
 
cy_en_profile_status_t Cy_Profile_GetWeightedCount (cy_stc_profile_ctr_ptr_t ctrAddr, uint64_t *result)
 Reports the count value for a specified counter, multiplied by the weight factor for that counter. More...
 
uint64_t Cy_Profile_GetSumWeightedCounts (cy_stc_profile_ctr_ptr_t ptrsArray[], uint32_t numCounters)
 Reports the weighted sum result of the first n number of counter count values starting from the specified profile counter data structure base address. More...
 

Function Documentation

◆ Cy_Profile_GetRawCount()

cy_en_profile_status_t Cy_Profile_GetRawCount ( cy_stc_profile_ctr_ptr_t  ctrAddr,
uint64_t *  result 
)

Reports the raw count value for a specified counter.

Parameters
ctrAddrThe handle to the assigned counter, (returned by calling Cy_Profile_ConfigureCounter()).
resultOutput parameter used to write in the result.
Returns
Status of the operation.
Function Usage
/* Scenario: The raw count value of profile counter assigned to position #0
in the previous profiling window needs to be read. */
/* 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 */
/* Variable for storing the raw count */
uint64_t rawCnt;
/* Get the raw count value of profile counter #0 */
if(CY_PROFILE_SUCCESS != Cy_Profile_GetRawCount(cntHandle[0], &rawCnt))
{
/* Insert error handling */
}

◆ Cy_Profile_GetWeightedCount()

cy_en_profile_status_t Cy_Profile_GetWeightedCount ( cy_stc_profile_ctr_ptr_t  ctrAddr,
uint64_t *  result 
)

Reports the count value for a specified counter, multiplied by the weight factor for that counter.

Parameters
ctrAddrThe handle to the assigned counter, (returned by calling Cy_Profile_ConfigureCounter()).
resultOutput parameter used to write in the result.
Returns
Status of the operation.
Function Usage
/* Scenario: The weighted count value of the profile counter assigned to
position #0 in the previous profiling window needs to be read. */
/* List of handles for allocated counters */
cy_stc_profile_ctr_ptr_t cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};
/* Start the profiling window */
/* When ready to read the results of the counter values, stop the profiling window. */
/* Variable for storing the weighted count */
uint64_t weightedCnt;
/* Get the weighted count value of profile counter #0 */
if(CY_PROFILE_SUCCESS != Cy_Profile_GetWeightedCount(cntHandle[0], &weightedCnt))
{
/* Insert error handling */
}

◆ Cy_Profile_GetSumWeightedCounts()

uint64_t Cy_Profile_GetSumWeightedCounts ( cy_stc_profile_ctr_ptr_t  ptrsArray[],
uint32_t  numCounters 
)

Reports the weighted sum result of the first n number of counter count values starting from the specified profile counter data structure base address.

Each count value is multiplied by its weighing factor before the summing operation is performed.

Parameters
ptrsArrayBase address of the profile counter data structure
numCountersNumber of measured counters in ptrsArray[]
Returns
The weighted sum of the specified counters
Function Usage
/* Scenario: The weighted average of assigned profile counters in positions
#0 to #5 in the previous profiling window needs to be read. */
/* List of handles for allocated counters */
cy_stc_profile_ctr_ptr_t cntHandle[PROFILE_PRFL_CNT_NR] = {0UL};
/* Start the profiling window */
/* When ready to read the results of the counter values, stop the profiling window */
/* Energy limit (example) of a profiling window */
uint64_t energyLimit = 0x00020000UL;
/* Get the weighted average of assigned profile counters in positions #0 to #5 */
uint64_t weightedAvg = Cy_Profile_GetSumWeightedCounts(&cntHandle[0], 6UL);
if(weightedAvg > energyLimit)
{
/* The energy consumption is more than expected for this profiling window.
Take appropriate measures to reduce the energy consumption. */
}