Is TIMER_getCount just a one cycle read (on a c6711)? Or could it take a variable number of cycles based on caching or something else?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Is TIMER_getCount just a one cycle read (on a c6711)? Or could it take a variable number of cycles based on caching or something else?
Each count corresponds to 4 CPU cycles.
Please see pages 4/5 of the document Signal Processing Examples Using the TMS320C67x Digital Signal Processing Library (DSPLIB)
"The maximum resolution of the timer is 4 CPU cycles since the input to the timer is fixed to the
CPU clock, divided by four. The function call overhead for the TIMER_getCount() is roughly
measured and compensated."
What does "The function call overhead for the TIMER_getCount() is
roughly measured and compensated" mean?
What I'm looking to do is measure the period (in timer counts) of a sine wave (with a hardware zero crossing detector) very accurately. I am pulling the value off with TIMER_getCount and subtracting from the previous to get the difference. Then I am taking many many periods and finding the average. What I find is I have a very slight bias in the average timer counts .25 timer counts off (I need to meaure my sine wave very accurately) . I was thinking that if TIMER_getCount could take a variable number of cycles to run then that could cause this issue. For example if the API call takes 2 cycles most of the time but takes 3 cycles every now and then (because of cacheing or some other issue).
bryce johnson said:What does "The function call overhead for the TIMER_getCount() is roughly measured and compensated" mean?
In the code snippet above this statement in the document that Mariana pointed you to, there is a reasonable attempt at measuring the function call overhead. Then that measurement is used to compensate for that overhead when the actual timing measurement is made.
There will be variation, but 25 is probably about the overhead of the call. Are you following the advice to which Mariana pointed you? If so, we have a different issue to deal with. If not, please look at that document and use the example for your measurements.