<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Millisecond counter in case of FreeRTOS usage</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66534/millisecond-counter-in-case-of-freertos-usage</link><description>I have as starting point the HRS FreeRTOS app. Now I want to add a millisecond counter. But from what I read I&amp;#39;m a little bit confused. Can someone tell me what&amp;#39;s the best route to do. a) In FreeRTOS you can get a tick count with xTaskGetTickCount. Is</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 08 Oct 2020 12:15:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66534/millisecond-counter-in-case-of-freertos-usage" /><item><title>RE: Millisecond counter in case of FreeRTOS usage</title><link>https://devzone.nordicsemi.com/thread/273729?ContentTypeID=1</link><pubDate>Thu, 08 Oct 2020 12:15:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff031012-3183-4a07-a1d8-f4ac76c5d9d3</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]In &lt;strong&gt;FreeRTOS&lt;/strong&gt; you can get a tick count with xTaskGetTickCount. Is the the best route? And how to convert it then to milliseconds because the configTICK_RATE_HZ is set to 1024 in the HRS example?[/quote]
&lt;p&gt;&amp;nbsp;One second is 1024 ticks, so 1 ms = ticks/1024*1000.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Look at the definition of APP_TIMER_TICKS in app_timer.h for inspiration on how you can implement this calculation.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Perhaps:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;PASSED_MS(TICKS) (uint32_t)ROUNDED_DIV((TICKS)*1000,configTICK_RATE_HZ)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The same applies for b), except that the tick rate is different. The app timer is running at 32768Hz.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>