Quantcast
Channel: Embedded Software (Read Only)
Viewing all articles
Browse latest Browse all 25965

Forum Post: RE: DMTimer TLDR value calculation - TRM conflicts with with StarterWare code?

$
0
0

I'm going to answer this so that anybody else looking for the answer to this question can hopefully find it. I'm pretty sure I'm correct, unless somebody from TI wants to contradict me with evidence.

The StarterWare sysdelay code is incorrect. The code in the Sysdelay function should be:

unsignedintcountVal=TIMER_OVERFLOW-(milliSec*TIMER_1MS_COUNT - 1);

where the minus one is the part that's currently missing.

To verify this, I set up my thread to delay for 500 milliseconds at a time (my RTOS clock ticks every millisecond). Every time my thread wakes back up, I read the value of a second DMTimer which I configured to run with sub-microsecond resolution and convert to microseconds. Without the minus one, the difference in the second timer is consistently 500020 +/- 1 us. That is exactly what I would expect to see if there were 500 * (1/24000000) extra clock pulses happening every half second. If I subtract one from the TLDR value as stated in the TRM, the time difference comes out to be 500000 +/- 1 us which is bang on. 

Hope other people find this useful.

Matt T


Viewing all articles
Browse latest Browse all 25965

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>