<?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>FreeRTOS : understanding vTaskDelay() import of Nordic SDK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86008/freertos-understanding-vtaskdelay-import-of-nordic-sdk</link><description>using RF5_SDK_15.2.0 and looking at the one of the examples: blinky with freeRTOS: 
 nRF5_SDK_15.2.0_9412b96\examples\peripheral\blinky_freertos\main.c 
 I see that in the function call to vTaskDelay there is no division by portTICK_PERIOD_MS 
 how do</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 23 Mar 2022 09:33:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86008/freertos-understanding-vtaskdelay-import-of-nordic-sdk" /><item><title>RE: FreeRTOS : understanding vTaskDelay() import of Nordic SDK</title><link>https://devzone.nordicsemi.com/thread/359541?ContentTypeID=1</link><pubDate>Wed, 23 Mar 2022 09:33:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec5fc797-5d33-4735-a48b-df8b7992fba6</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I think this example was written when we incorrectly used&amp;nbsp;&lt;span&gt;configTICK_RATE_HZ as 1000 which made the developer assume that 1 tick = 1ms.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Later we realized that with RTC 1000 ticks cannot be produced so we change the tick rate to 1024 and yes that meant that each tick is around 0.9765ms.&lt;br /&gt;So it is documentation bug to say that TASK_DELAY is 200ms and not 200 ticks.&lt;/span&gt;&lt;/p&gt;
[quote user=""]how do you guarantee vTaskDelay to work in ms time ? since this is contradicting the following article from freeRTOS :&amp;nbsp;&lt;a href="https://www.freertos.org/a00127.html"&gt;https://www.freertos.org/a00127.html&lt;/a&gt;[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;portTICK_PERIOD_MS is practically useless with this prescalar. Like you have figured out this will give 0 and hence all your conversions using this will be incorrect. There will be no exact conversion of ms to ticks without using float, so I can suggest you use something like this&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define portMS_FROM_TICKS_CUSTOM(X)            ( (X * 1000) / configTICK_RATE_HZ )

#define portTICKS_FROM_MS(X)                   ( (X *configTICK_RATE_HZ) / 1000 )&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;This will be very inefficient the lower the X gets. If you want better accuracy with timings and conversions to be very accurate, then I do not think using RTC as main RTOS clock works for you. Then you need to use other high accuracy clocks.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>