cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Anonymous
Not applicable

 What is the best method to measure time for an operation......I tried using a pin and toggling it within a for loop continuosly......But even time is taken for setting the pin and resetting it.....Any other ideas......

0 Likes
5 Replies
rotec_264361
New Contributor II

Hi,

   

accuracy and resolution might struggling with each other here. I can recommend a reproducable method.

   

Use a timer with the maximum possible input frequency (max resolution). Reset the timer to zero before the operation starts. The first instruction of your operation is starting the timer. The first instruction after the operation is stoppong the timer. Now you read out the timer and display the value through a serial channel, on a LCD display, in the debugger, which ever method you'd like to use.

   

hth

0 Likes
JoMe_264151
Expert II

You may even count the calls of your function and add all the timer-values so you might calculate an average.

   

 

   

Bob

0 Likes
HeLi_263931
Honored Contributor II

When you want to do some accurate measurement. you need to make multiple calls to the code in question. Otherwise the delays and the overhead of the time measurement code will lead to wrong results.

0 Likes
ETRO_SSN583
Esteemed Contributor

Some usefull references, attached -

   

 

   

Regards, Dana

0 Likes
Anonymous
Not applicable

 Toggling pins is a good idea, if you run the code within the for loop......for any accurate measurement to be done please go to the "generated code " folder where the project is placed and in this folder look for "main.lst "file. Open this file and you can see how each line of code is being made of asembly instructions......Calculate the total cycles taken and multiply with the 1/Bus frequency this will be accurate way of measurement

0 Likes