2 Replies Latest reply on Aug 17, 2016 9:07 AM by user_342122993

    Code execution time

    amar230292_1754041

      Is there any way to find how long a part of my code take to complete execution on psoc 5lp?

         

       

         

      Thank you

        • 1. Re: Code execution time
          user_1377889

          Use a logic analyzer and flip a port. If it is a lengthy program part use a timer/counter component as a clock and read the values at begin and end.

             

           

             

          Bob

          • 2. Re: Code execution time
            user_342122993
                    creative, 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 SysTick_Config(SYSTICK_MAXVAL); //reset counter set to max value, 1-time, will not reload TCPWM_WritePeriod(); // your function is here... 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);