- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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......
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may even count the calls of your function and add all the timer-values so you might calculate an average.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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