<?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>Random number without softdevice</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19429/random-number-without-softdevice</link><description>Hi, 
 I am working with nRF51 for my application. I do not use softdevices. I need to have a random variable in my code. I have read Reference Manual and I have found that random numbers can be made by RNG. Some registers are described in documentation</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 03 Feb 2017 21:40:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19429/random-number-without-softdevice" /><item><title>RE: Random number without softdevice</title><link>https://devzone.nordicsemi.com/thread/75465?ContentTypeID=1</link><pubDate>Fri, 03 Feb 2017 21:40:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db510fca-d9a1-4b75-b0d4-bad58f4efd4a</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;Thanks for posting.  I think that may come in handy, albeit I could just use the driver in my case ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Random number without softdevice</title><link>https://devzone.nordicsemi.com/thread/75464?ContentTypeID=1</link><pubDate>Fri, 03 Feb 2017 20:25:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f6d6ff0c-3d2a-4918-8035-112da762e127</guid><dc:creator>CurtisHx</dc:creator><description>&lt;p&gt;The RNG is probably one of the most simple peripherals to run on the nRF5s.  Here&amp;#39;s the way we did it (bare metal) to generate a random number.&lt;/p&gt;
&lt;p&gt;From the functional description in the nRF51 Reference Manual&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The RNG is started by triggering the START task and stopped by triggering the STOP task. When started, new random
numbers are generated continuously and written to the VALUE register when ready. A VALRDY event is generated for
every new random number that is written to the VALUE register. This means that after a VALRDY event is generated
the CPU has the time until the next VALRDY event to read out the random number from the VALUE register before it is
overwritten by a new random number&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Basically, start the RNG, wait for the VALRDY, stop the RNG, and read out the random number. It&amp;#39;s really, &lt;em&gt;really&lt;/em&gt; simple.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t GenerateRandomNumber()
{
   NRF_RNG_VALRDY = 0;
   NRF_RNG-&amp;gt;TASKS_START = 1;
   while(NRF_RNG-&amp;gt;VALRDY == 0){}
   NRF_RNG-&amp;gt;TASKS_STOP = 1;
   return NRF_RNG-&amp;gt;VALUE;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Random number without softdevice</title><link>https://devzone.nordicsemi.com/thread/75463?ContentTypeID=1</link><pubDate>Fri, 03 Feb 2017 13:18:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:36a6b4e9-1f65-4d44-aef4-c20c495894ef</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There is a &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.2.0/rng_example.html?cp=4_0_1_4_5_27"&gt;RNG example&lt;/a&gt; in the SDK:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;SDK_InstallFolder&amp;gt;\examples\peripheral\rng
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you dont want to use the SDK RNG driver, you can also find a bare-metal example on how to use the RNG peripheral &lt;a href="https://github.com/andenore/NordicSnippets/blob/master/examples/rng/main.c"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>