Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
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......
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.
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