This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Random number generator not so random

Hello DevZone,

SDK 15.0.0, sd132

I'm working on the random number generator peripheral in the nRF52832 and used the peripheral example in my SDK.

When I upload the example code to my devkit I can clearly see that every time the microcontroller boots the numbers differ from each other.

When I want to implement that feature in my project, using the same lines of code and files and settings (I believe) it always seems to give me the same number.

Even across multiple devkits. 

So can anyone tell me what I'm doing wrong here?

Kind regards

Parents Reply
  • I haven't used this peripheral but I prefer writing home-brew rather than the abstracted libraries in most cases as you can tell what's going on. Some things come to mind, the obvious one is the library probably uses interrupts and you are not. Second is the RND is probably used by SoftDevice (I guess) for the encrypted connection so maybe the nrf library is calling it and you have a problem there.

    If you're doing this on boot before softdevice init and without need to refresh the numbers I'd be happy with your approach, with a loop for however many you need.

Children
Related