Profiling PSOC4 code

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

   

 

   

In psoc creator,

   

how can I profile the code and know how much resourses each function takes?

   

 

   

Br,

   

Fayek

0 Likes
1 Reply
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

There is no profiler in Creator AFAIK. You can yse SysTick counter to measure amount of CPU cycles taken by a function or operation as shown below. You will be limited by 2^24 CPU ticks only (about 0.25sec @24MHz CPU speed), as SysTick counter on Cortex M0 and M3 can not go beyond  SYSTICK_MAXVAL.

   

odissey1

   

 

   

 

   

#define SYSTICK_MAXVAL 0x00FFFFFF //max allowed SysTick counter value for 24bit

   

uint32 SysCntVal; // The value of SysTick counter you are trying to retrieve
 

   

float x=1.0f; //some variable to work with    
        
      SysTick_Config(SYSTICK_MAXVAL); //reset counter set to max value, 1-time,  will not reload

   

      x+=(float) 0.0001; //do something.. 

   

      SysCntVal = SYSTICK_MAXVAL - (SysTick->VAL); //get elapsed ticks (min offset 3 ticks)
           
      sprintf(strMsg1, "%d, %f\r\n", SysCntVal, x); //report result
      UART_PutString(strMsg1);

0 Likes