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

PSoC™ 4

DeAa_335316
Level 4
First like received
Level 4

Hello,

I have developed c code by using PSoc Creator and i want to know about how to test performance of developed code.

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

You can measure amount of CPU clock cycles consumed by some piece of code using custom StopWatch component (attached). It uses system SysTick timer to count CPU cycles. The component is rather unfinished, but works for PSoC4, 4M and 5LP. To measure CPU clocks put StopWatch_Start() and StopWatch_Stop() in your code, and print result on terminal:

StopWatch_Start() ; // reset timer

// your code is here (function, ISR, etc.)

.....

StopWatch_Stop() ; // stop timer

uint32 BusClockTicks = StopWatch_Cycles; // read result

To add StopWatch component to you project, Import it from the demo project attached.

StopWatch_P4M_01a.png

StopWatch_P4M_01.PNG

View solution in original post

3 Replies
HeLi_263931
Level 8
100 likes received 50 likes received 25 likes received
Level 8

Do you want to do a unit-test (as in 'testing for correctness') or a performance test (as in 'how fast is it')? For the former, I can recommend the combination of Ceedling, CMock and Unity. Note that especially mocking can be interesting since you need to abstract from your hardware.

0 Likes
Bob_Marlowe
Level 10
50 questions asked 10 questions asked 1000 solutions authored
Level 10

And for the second case (how fast...) use a logic analyzer and toggle a pin to see how fast things go on...

Bob

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

You can measure amount of CPU clock cycles consumed by some piece of code using custom StopWatch component (attached). It uses system SysTick timer to count CPU cycles. The component is rather unfinished, but works for PSoC4, 4M and 5LP. To measure CPU clocks put StopWatch_Start() and StopWatch_Stop() in your code, and print result on terminal:

StopWatch_Start() ; // reset timer

// your code is here (function, ISR, etc.)

.....

StopWatch_Stop() ; // stop timer

uint32 BusClockTicks = StopWatch_Cycles; // read result

To add StopWatch component to you project, Import it from the demo project attached.

StopWatch_P4M_01a.png

StopWatch_P4M_01.PNG