<?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>CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86839/crc-on-the-nrf52840</link><description>Hello! 
 Regarding the CRC on the nrf52840 the specifications make it clear that the maximum length of the CRC is 3 bytes, We are working on an industrial communication protocol that we want to implement on the nrf52840. This protocol needs 4 bytes crc</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 25 Apr 2022 08:06:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86839/crc-on-the-nrf52840" /><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/364622?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2022 08:06:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26902312-d802-4349-a10a-50cf186df552</guid><dc:creator>kongstrupp</dc:creator><description>&lt;p&gt;Thanks a lot Edvin!!!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is great, When doing the crc32_compute I got 3 ticks which is less than 1&amp;nbsp;&lt;span&gt;&amp;micro;s, do you think this is legit? It seems really really fast.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If its legit it means that the algorithm is really fast in itself, but then it becomes a question if it could be used on received packets in the radio an how long that takes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Just posting the code that I used:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;uint32_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;crc32_compute&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;uint8_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; * &lt;/span&gt;&lt;span&gt;p_data&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;uint32_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;size&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;uint32_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; * &lt;/span&gt;&lt;span&gt;p_crc&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;uint32_t&lt;/span&gt;&lt;span&gt; crc;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; crc = (p_crc == &lt;/span&gt;&lt;span&gt;NULL&lt;/span&gt;&lt;span&gt;) ? &lt;/span&gt;&lt;span&gt;0xFFFFFFFF&lt;/span&gt;&lt;span&gt; : ~(*p_crc);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;for&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;uint32_t&lt;/span&gt;&lt;span&gt; i = &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;; i &amp;lt; size; i++)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; crc = crc ^ &lt;/span&gt;&lt;span&gt;p_data&lt;/span&gt;&lt;span&gt;[i];&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;for&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;uint32_t&lt;/span&gt;&lt;span&gt; j = &lt;/span&gt;&lt;span&gt;8&lt;/span&gt;&lt;span&gt;; j &amp;gt; &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;; j--)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; crc = (crc &amp;gt;&amp;gt; &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;) ^ (&lt;/span&gt;&lt;span&gt;0xEDB88320&lt;/span&gt;&lt;span&gt; &amp;amp; -(crc &amp;amp; &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;));&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;return&lt;/span&gt;&lt;span&gt; ~crc;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;test_timer&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;uint32_t&lt;/span&gt;&lt;span&gt; sample_1;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;uint32_t&lt;/span&gt;&lt;span&gt; sample_2;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;// Configure and start timer:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;NRF_TIMER3&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;BITMODE&lt;/span&gt;&lt;span&gt; &amp;nbsp; &amp;nbsp; = TIMER_BITMODE_BITMODE_32Bit &amp;lt;&amp;lt; TIMER_BITMODE_BITMODE_Pos;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;NRF_TIMER3&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;MODE&lt;/span&gt;&lt;span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= TIMER_MODE_MODE_Timer &amp;lt;&amp;lt; TIMER_MODE_MODE_Pos;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;NRF_TIMER3&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;PRESCALER&lt;/span&gt;&lt;span&gt; &amp;nbsp; = &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;NRF_TIMER3&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;TASKS_START&lt;/span&gt;&lt;span&gt; = &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;uint8_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;packetCRC&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;43&lt;/span&gt;&lt;span&gt;];&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;for&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;uint8_t&lt;/span&gt;&lt;span&gt; i = &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;; i &amp;lt; &lt;/span&gt;&lt;span&gt;sizeof&lt;/span&gt;&lt;span&gt;(packetCRC) - &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;; i++) {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;packetCRC&lt;/span&gt;&lt;span&gt;[i + &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;] = &lt;/span&gt;&lt;span&gt;0xCC&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;NRF_TIMER3&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;TASKS_CAPTURE&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;] = &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;; &amp;nbsp; &lt;/span&gt;&lt;span&gt;// Take first timestamp&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;crc32_compute(packetCRC,sizeof(packetCRC),NULL); // Do something that takes time&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;NRF_TIMER3&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;TASKS_CAPTURE&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;] = &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;; &amp;nbsp; &lt;/span&gt;&lt;span&gt;// Take second timestamp&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; sample_1 = &lt;/span&gt;&lt;span&gt;NRF_TIMER3&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;CC&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;]; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;// Read out first timestamp&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; sample_2 = &lt;/span&gt;&lt;span&gt;NRF_TIMER3&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;CC&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;]; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;// Read out second timestamp&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;uint32_t&lt;/span&gt;&lt;span&gt; diff_time = sample_2 - sample_1; &amp;nbsp; &lt;/span&gt;&lt;span&gt;// Calculate diff&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;printk&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;quot;test_timer used &lt;/span&gt;&lt;span&gt;%d&lt;/span&gt;&lt;span&gt; ticks.&amp;quot;&lt;/span&gt;&lt;span&gt;, diff_time); &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;// Note that clock ticks at 16 000 000 Hz&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;main&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;test_timer&lt;/span&gt;&lt;span&gt;();&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/364507?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 14:02:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e4f34f4-8343-4359-bc7d-c6491b690196</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I see that you created a new ticket, where a colleague of mine answered one way to measure the time. However, this will work for ms (seconds/1000), but you probably want a higher resolution.&lt;/p&gt;
&lt;p&gt;I am not sure whether there are any libraries in Zephyr that you can use to measure µs, but you can use the TIMER peripheral.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Try running this function from the hello world sample:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void test_timer(void)
{
    uint32_t sample_1;
    uint32_t sample_2;
    // Configure and start timer:
    NRF_TIMER3-&amp;gt;BITMODE     = TIMER_BITMODE_BITMODE_32Bit &amp;lt;&amp;lt; TIMER_BITMODE_BITMODE_Pos;
    NRF_TIMER3-&amp;gt;MODE        = TIMER_MODE_MODE_Timer &amp;lt;&amp;lt; TIMER_MODE_MODE_Pos;
    NRF_TIMER3-&amp;gt;PRESCALER   = 0;
    NRF_TIMER3-&amp;gt;TASKS_START = 1;

    NRF_TIMER3-&amp;gt;TASKS_CAPTURE[0] = 1;   // Take first timestamp
    k_sleep(K_MSEC(1000));              // Do something that takes time
    NRF_TIMER3-&amp;gt;TASKS_CAPTURE[1] = 1;   // Take second timestamp

    sample_1 = NRF_TIMER3-&amp;gt;CC[0];       // Read out first timestamp
    sample_2 = NRF_TIMER3-&amp;gt;CC[1];       // Read out second timestamp

    uint32_t diff_time = sample_2 - sample_1;   // Calculate diff

    LOG_INF(&amp;quot;test_timer used %d ticks.&amp;quot;, diff_time);    // Note that clock ticks at 16 000 000 Hz
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Just copy this function and call it from main.c.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As I wrote in the last comment in this snippet, note that the TIMER is running at 16MHz, so 1 second = 16000000 ticks, which means that 1µs would be 16 ticks. This is the highest resolution you can get with a timer onboard the nRF52840.&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><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/364466?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 12:03:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9613b853-f4de-4a8c-9c3b-486eb1dea4b6</guid><dc:creator>kongstrupp</dc:creator><description>&lt;p&gt;No I think the libraries does not support it. I am currently looking into a soft way of doing it, I need some kind of function that would help me do what is described above. Yes that is one way of doing it, I will have to look into it more&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/364464?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 11:57:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21b02667-5357-4759-90e8-900de194e626</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;This can be one way of doing it.&lt;/p&gt;
[quote user="kongstrupp"]&lt;div&gt;&lt;span&gt;this could to be a way of doing it, but it does not seem to work in nrf connect extension in VScode.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;What do you suggest?&lt;/div&gt;[/quote]
&lt;p&gt;Why does it not work? Does it not compile? Is it not able to calculate the time?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am not that familiar with the time libraries in NCS. Another simple way to test this is to toggle a pin before and after the calculations (crc32_compute()), and then monitor this using a logic analyzer or an oscilloscope.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/364455?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 11:39:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69dd9e38-75f2-41ca-b8c5-3dd130d08bbe</guid><dc:creator>kongstrupp</dc:creator><description>&lt;p&gt;Yes there is a CRC after each of the green sections, Yes, the total length of the downlink is 52 bytes. Which means the CRC will be calculated on the 43 bytes of the downlink since preamble and syncword&amp;nbsp; does not count (5 bytes) and&amp;nbsp; i assume that you dont count CRC on CRC. So 52-9 = 43&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/UplinkSSlotDGUARD.PNG" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Here you can see a picture of an uplink (the green slots in the picture above) and after that a D_GUARD which is 8 us&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How do you test this in a sufficent way? I assume that you would just use the&amp;nbsp;&lt;span&gt;crc32_compute()&amp;nbsp;function. So maybe generate a hello_world program and do something like this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-1"&gt;&lt;span class="c-p"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-2"&gt;&lt;span class="c-p"&gt;#include &amp;lt;time.h&amp;gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// for time()&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-3"&gt;&lt;span class="c-p"&gt;#include &amp;lt;unistd.h&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// for sleep()&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-4"&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-5"&gt;&lt;span class="c-c"&gt;// main function to find the execution time of a C program&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-6"&gt;&lt;span class="c-t"&gt;int&lt;/span&gt;&lt;span class="c-h"&gt; &lt;/span&gt;&lt;span class="c-e"&gt;main&lt;/span&gt;&lt;span class="c-sy"&gt;(&lt;/span&gt;&lt;span class="c-sy"&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-7"&gt;&lt;span class="c-sy"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-8"&gt;&lt;span class="c-h"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="c-e"&gt;time_t &lt;/span&gt;&lt;span class="c-v"&gt;begin&lt;/span&gt;&lt;span class="c-h"&gt; &lt;/span&gt;&lt;span class="c-o"&gt;=&lt;/span&gt;&lt;span class="c-h"&gt; &lt;/span&gt;&lt;span class="c-e"&gt;time&lt;/span&gt;&lt;span class="c-sy"&gt;(&lt;/span&gt;&lt;span class="c-t"&gt;NULL&lt;/span&gt;&lt;span class="c-sy"&gt;)&lt;/span&gt;&lt;span class="c-sy"&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-9"&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-10"&gt;&lt;span class="c-h"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span&gt;crc32_compute() // some bytes to do CRC on&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-11"&gt;&lt;span class="c-h"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="c-e"&gt;sleep&lt;/span&gt;&lt;span class="c-sy"&gt;(&lt;/span&gt;&lt;span class="c-cn"&gt;3&lt;/span&gt;&lt;span class="c-sy"&gt;)&lt;/span&gt;&lt;span class="c-sy"&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-12"&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-13"&gt;&lt;span class="c-h"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="c-e"&gt;time_t &lt;/span&gt;&lt;span class="c-st"&gt;end&lt;/span&gt;&lt;span class="c-h"&gt; &lt;/span&gt;&lt;span class="c-o"&gt;=&lt;/span&gt;&lt;span class="c-h"&gt; &lt;/span&gt;&lt;span class="c-e"&gt;time&lt;/span&gt;&lt;span class="c-sy"&gt;(&lt;/span&gt;&lt;span class="c-t"&gt;NULL&lt;/span&gt;&lt;span class="c-sy"&gt;)&lt;/span&gt;&lt;span class="c-sy"&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-14"&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-15"&gt;&lt;span class="c-h"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="c-c"&gt;// calculate elapsed time by finding difference (end - begin)&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-16"&gt;&lt;span class="c-h"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="c-r"&gt;printf&lt;/span&gt;&lt;span class="c-sy"&gt;(&lt;/span&gt;&lt;span class="c-s"&gt;&amp;quot;The elapsed time is %d seconds&amp;quot;&lt;/span&gt;&lt;span class="c-sy"&gt;,&lt;/span&gt;&lt;span class="c-h"&gt; &lt;/span&gt;&lt;span class="c-sy"&gt;(&lt;/span&gt;&lt;span class="c-st"&gt;end&lt;/span&gt;&lt;span class="c-h"&gt; &lt;/span&gt;&lt;span class="c-o"&gt;-&lt;/span&gt;&lt;span class="c-h"&gt; &lt;/span&gt;&lt;span class="c-v"&gt;begin&lt;/span&gt;&lt;span class="c-sy"&gt;)&lt;/span&gt;&lt;span class="c-sy"&gt;)&lt;/span&gt;&lt;span class="c-sy"&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-17"&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-18"&gt;&lt;span class="c-h"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="c-st"&gt;return&lt;/span&gt;&lt;span class="c-h"&gt; &lt;/span&gt;&lt;span class="c-cn"&gt;0&lt;/span&gt;&lt;span class="c-sy"&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line" id="c-6252ff2e6db11301913109-19"&gt;&lt;span class="c-sy"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line"&gt;&lt;span class="c-sy"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line"&gt;&lt;span class="c-sy"&gt;this could to be a way of doing it, but it does not seem to work in nrf connect extension in VScode.&lt;/span&gt;&lt;/div&gt;
&lt;div class="c-line"&gt;What do you suggest?&lt;/div&gt;
&lt;div class="c-line"&gt;&lt;/div&gt;
&lt;div class="c-line"&gt;Best regards&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/364432?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 10:45:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63fe00dc-38a8-4abb-b865-22bf21c7f92e</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Is there a CRC after each of the green sections (before the red sections)? Or is it a CRC after the entire thing in the picture? And is the CRC dependent on the downlink, or can you generate it before the downlink?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="kongstrupp"]This guard interval is 8 us, which means that the master (considering this software solution) needs to be able to calculate a 4 byte CRC within LESS than 8 us[/quote]
&lt;p&gt;I did not forget to answer this, but I don&amp;#39;t know how long it takes. You would need to test this. I guess it depends on what else the nRF is doing at the time, and even if it is doing this as the highest priority I don&amp;#39;t know how long this function call will take. It probably depends on the length of what you need to generate the CRC of. Before you ask, I don&amp;#39;t know how large a packet you could generate a 4byte CRC below 8µs is either. You need to test.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/364422?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 10:11:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2b807bb-6e18-47ab-af96-8ee397d088c0</guid><dc:creator>kongstrupp</dc:creator><description>&lt;p&gt;I see, I will try to summarize the timing scheme within the IO-Link Wireless protocol as much as I can.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Down below a picture of a sub-cycle between master and slave is shown. This is a scheme that show a complete communication exchange between master and slave.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img height="149" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/w_2D00_subcycle.PNG" width="411" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;As you can see the yellow part is the downlink (master to slave), and the green parts are the uplinks (slave to master). So a downlink is sent from the master and received by all slaves, and then, the uplinks are returned in a special order to the master.&lt;/p&gt;
&lt;p&gt;At the end of each uplink and downlink the IO-Link Wireless protocol requires a 4 byte CRC. Note that between each green slot, there is a red interval to avoid collision on air (guard interval). This guard interval is 8 us, which means that the master (considering this software solution) needs to be able to calculate a 4 byte CRC within LESS than 8 us&lt;/p&gt;
&lt;p&gt;So, we are very interested in knowing if the CPU is able to do this. Can it calculate a 4 byte CRC this fast? Is there a way to measure the processors execution time? I looked online and it seems to be a bit more complicated that I thought. Please let me know if this information that I have just provided is not sufficient for you to be able to determine weather or not this is possible.&lt;/p&gt;
&lt;p&gt;Thanks a lot Edvin for you inputs really means a grate deal for us&amp;nbsp;&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/364275?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 13:54:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a80c175-2e25-4ca5-a8da-1ea3409cecd7</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I was thinking about writing something about timing in my reply yesterday, but I skipped it &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know anything about this protocol that you want to use, other than that it has a 4 byte CRC. But what I know from BLE is that in this case, a SW based CRC would probably not work, since the timing requirements are very strict, and the peripheral/server/slave needs to modify the reply packet based on the incoming packet, and then generate a CRC in a very short time. So whether it will work or not probably depends on timing. I guess you just need to test and see.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/364265?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 13:41:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2f750af-2263-416e-a8ce-68017a8f2c3c</guid><dc:creator>kongstrupp</dc:creator><description>&lt;p&gt;Well we really need to know how this shortcut of 4 bytes CRC would do in terms of timing and how effective it would be, since you said that it would be possible to add this extra CRC on received packets in the radio on the nrf52840.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/364248?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 13:18:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:015cbeab-2634-4857-8c88-f8b331648169</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Actually, I don&amp;#39;t think it is as effective as you may assume. I too need to look up things to be able to answer questions. Was there something in particular you wanted to ask?&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><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/364215?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 12:15:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04ecf24d-f6ad-41a1-a25e-42b98305e9a3</guid><dc:creator>kongstrupp</dc:creator><description>&lt;p&gt;Hello Edvin, Can we have a live meeting with you on Zoom? That would mean a great deal for us if you could, This is pretty hard to discuss in a forum like this&lt;/p&gt;
&lt;p&gt;Thanks a lot&lt;/p&gt;
&lt;p&gt;Best regards!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/363436?ContentTypeID=1</link><pubDate>Tue, 19 Apr 2022 07:18:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:442e0e67-110b-474a-9238-7691e0b81770</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I see. So just to clarify, you can not use the Bluetooth stack (Softdevice) for this. But if you were to implement your own radio protocol, you can implement a 4 byte CRC and attach it to the end of your payload. If you do this, please remember to disable the radio&amp;#39;s built in CRC, by setting the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/radio.html?cp=4_0_0_5_19_13_56#register.CRCCNF"&gt;NRF_RADIO-&amp;gt;CRCCNF&lt;/a&gt;&amp;nbsp;register to 0x00000000, which will exclude the HW CRC from the packet.&amp;nbsp;&lt;/p&gt;
[quote user="kongstrupp"]or maybe, the software &lt;span&gt;CRC&amp;nbsp;&lt;/span&gt;can complement the hardware &lt;span&gt;CRC&lt;/span&gt;?[/quote]
&lt;p&gt;That is more complicated. I wouldn&amp;#39;t recommend that.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/363196?ContentTypeID=1</link><pubDate>Wed, 13 Apr 2022 12:40:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:382e5e42-25a5-429a-98e7-d49f247f961d</guid><dc:creator>kongstrupp</dc:creator><description>&lt;p&gt;Okay I think there is some confusion but I will try to clarify a bit.&lt;/p&gt;
&lt;p&gt;So, IO-Link Wireless, uses a 4 byte CRC for each packet, it sends packets back and forth between slave and master and they both use a 4 byte CRC on each packet, when looking at the radio peripherals in the specification each received packet and transmitted packet uses the hardware module &lt;span&gt;CRC&amp;nbsp;&lt;/span&gt;which only support 3 bytes, consider this package down below, this is what is called a &amp;quot;configuration&amp;nbsp;downlink&amp;quot; in the IO-Link Wireless specification, it is a communication exchange from a master to a slave, it is used for configuration purposes.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/1007.configdownlink.PNG" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Now the big question, can you configure the radio it in such a way that it can still support 4 bytes &lt;span&gt;CRC&lt;/span&gt; via software? So hypothetically you implement an IO-Link Wireless stack on the nrf52840 board and use a 4 byte CRC but it works via software and NOT via the hardware module, or maybe, the software &lt;span&gt;CRC&amp;nbsp;&lt;/span&gt;can complement the hardware &lt;span&gt;CRC&lt;/span&gt;? so that is becomes 4 byte CRC.&amp;nbsp; Do you think that that is possible? and if so, how can you do that?&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/363074?ContentTypeID=1</link><pubDate>Tue, 12 Apr 2022 20:58:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a02f1d29-4975-4df0-ba07-e6abdf503201</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;That depends on how the IO-Link Wireless does this. To be fair, I don&amp;#39;t think that everyone using this protocol has written their own Bluetooth stacks (but they could of course be using some sort of open source stack. I don&amp;#39;t know). If they use 4 bytes instead of 3, they will also be breaking the specification, so they will not be able to certify it with Bluetooth SIG.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you sure that the 4 byte CRC is not just added to the Bluetooth payload packet (and then the standard 3 byte CRC follows after that)? I am not familiar with IO link (in fact I never heard of it before now), and a quick google search didn&amp;#39;t really make me a lot smarter on that topic. Either way, if your question is whether it is possible to increase the CRC from 3 to 4 bytes inside our Bluetooth stack, then I am afraid the answer is no.&lt;/p&gt;
&lt;p&gt;But if that is the case, I doubt that there exists another wireless protocol that is an exact copy of the Bluetooth Low Energy standard, with the only difference being one extra byte of CRC, so in that case, I guess it wouldn&amp;#39;t work anyway.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It may be that I don&amp;#39;t understand this fully, but perhaps you can ask the developers/owners of IO-Link whether that is actually the case (that they are equivalent to BLE apart from the amount of CRC bytes)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/363062?ContentTypeID=1</link><pubDate>Tue, 12 Apr 2022 14:35:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f2183b8-3228-4254-9539-41b5f1a79fcc</guid><dc:creator>kongstrupp</dc:creator><description>&lt;p&gt;Okay fair enough, What we are trying to figure out is whether the nrf52840 will be able to support an industrial communication protocol called IO-Link Wireless. This protocol builds upon Bluetooth Low Energy version 4.2, but it requires 4 bytes CRC instead of 3. With that information, do you conclude that the nrf52840 board will not be able to support IO-Link Wireless since it has this specification?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/363040?ContentTypeID=1</link><pubDate>Tue, 12 Apr 2022 13:34:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a30c8ca2-6b02-41c4-9b9e-e145bc72e615</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Depends on what you intend to use it for. Yes. The nRF52840 can generate a 4 byte CRC. No, it can not use this 4 byte CRC instead of the 3 byte CRC in the end of Bluetooth Low Energy packets, because the Bluetooth stack uses a 3 byte CRC. But I suspect you are not using Bluetooth, since you are using a 4 byte CRC?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/362898?ContentTypeID=1</link><pubDate>Mon, 11 Apr 2022 14:46:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c814e77-156f-455d-ba24-ae2de0972d3b</guid><dc:creator>kongstrupp</dc:creator><description>&lt;p&gt;So to clarify what you are suggesting, the nrf52840 is capable of a 4-byte crc? Do you just need to configure it in such a way?&lt;/p&gt;
&lt;p&gt;Am I understanding you correctly?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CRC on the nrf52840</title><link>https://devzone.nordicsemi.com/thread/362868?ContentTypeID=1</link><pubDate>Mon, 11 Apr 2022 13:03:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54b9a2a6-0a83-4383-8741-64dd7afb3716</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The 3 byte CRC is first and foremost the standard of Bluetooth Low Energy, and not specific for the nRF52840.&lt;/p&gt;
&lt;p&gt;For a 4 byte CRC, check out the function crc32_compute() found in nRF5 SDK 17.1.0\components\libraries\crc32\crc32.c&lt;/p&gt;
&lt;p&gt;If you are using a different nRF5 SDK version, you will probably find something similar. If you are using NCS (and not the nRF5 SDK), there is probably something similar to that as well. In that case, please let me know if you can&amp;#39;t find it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>