In a very simple task containing an infinite loop and running on os_itv_wait() I would like to measure how long the code takes to run using os_time_get(). For example if os_itv_wait() lets my code run every 5 ticks and the difference between os_time_get() called at the top and bottom of my code is 2 ticks I know that I have time to spare. If the code takes 8 ticks I have a problem.
In my case I am running my code every 1 tick and can accept that occasionally the code runs in over 1 tick but I don't want it to take 2 ticks. Ideally therefore I'd like a sub-tick resolution timer but I haven't got that (without running a hardware timer which is a future possibility).
So for this test I'm looking to see if a whole tick has expired by the time I reach the end of the code - but this relies on the os_itv_wait() being synchronous and changing at the same time as the os_time_get() result and I don't know if they are.
For example, if os_itv_wait() allows my code to run but os_time_get() value changes 100us later I am likely to see a change between the top and bottom of my code times on every run.
I suspect that it is all driven from the same counter. A change in that counter value is synchronous with os_itv_wait() allowing my code to run and os_time_get() returning the new value.
Hi NPer, I understand both of those points and agree that a hardware timer is better. It doesn't answer the specific question about the relative timing of the two calls though. Any ideas? Thanks Ant
i found this on my computer
a timer is a clock that controls the sequence of an event while counting in fixed intervals of time. A Timer is used for producing precise time delay. Secondly, it can be used to repeat or initiate an action after/at a known period of time. This feature is very commonly used in several applications. An example could be setting up an alarm which triggers at a point of time or after a period of time.
it will help
Sorry Ali, I don't you understood the question.
nper did not tell you what a timer is so i look for information for you to help you
tell me what more information you want and i will try to help
one day i want to be a program
You should probably start with something simple.
Anyone else know if this is a single counter?