Important Note for time measurement in PSoC5

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

cross mob
Anonymous
Not applicable

 I wanted to measure the time taken for 32 bit addition and multiplication.....I chose the method of Pin toggling in for loop......

   

Something interesting happened ...

   

When I measured the time interval between the setting of pin and resetting the pin and multiply with the BUS clock the no. of cycles taken was coming up only to be 3. I was baffled irrespective of adition or multiplication the no. of CPU cycles was 3.

   

Then I went to main.lst file and looked at what was the issue. The assembly instructions after the operation in c code was somewhere missing, and seemed like the pin was reset before even the operation was done.

   

The compiler is crazy!!!!! Isnt it.........The reason why it happened was the optimisation level was set to speed and compiler did all it can.....

   

So while measuring with toggling of pins please keep the compiler optimisation for "none".

   

And one more interesting thing while trying to calculate the time taken for multiplication, please do not run the same operands in the for loop....compiler is intelligent...Try incrementing the operands before doing this..

   

             SMART COMPILER

0 Likes
0 Replies