hi,
I am working with nr52832 and SDK 12.1. I have referred the RNG example based on which I have integrated that code section in my custom application:
rng_generate(rand_arr1, RAND_STREAM_BYTES); //example output: 15234
rng_generate(rand_arr2, RAND_STREAM_BYTES); //15234
... user generated delay
rng_generate(rand_arr1, RAND_STREAM_BYTES); //23145
rng_generate(rand_arr2, RAND_STREAM_BYTES); //23145
and the code for rng_generate is:
void rng_generate(uint8_t *rand_arr, uint8_t len)
{
//nrf_drv_rng_config_t rand_config;
uint8_t bytes_avail;
uint32_t err_code;
err_code = nrf_drv_rng_bytes_available(&bytes_avail);
APP_ERROR_CHECK(err_code);
uint8_t length = (len<bytes_avail) ? len : bytes_avail;
err_code = nrf_drv_rng_rand(rand_arr,length);
APP_ERROR_CHECK(err_code);
}
I have initialised rng in main. My issue is: When I call the rng_generate twice immediately, I get the same number in rand_arr1 and rnad_arr2. This number changes after some user-generated delay is included (which is huge). But again if there are two immediate calls to rng_generate, I get the same number. I tried to include a few ms delay between them, but the results were same. How can I avoid this issue? Or is than any alternate api for generating true non-deterministic random numbers?
Thanks