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

non-random behaviour

Hi,

I'm trying to generate some time variant values for testing purposes... rand() always returns 1447534768! This is in the proximity app FWIW.

So, I thought I would use the hardware RNG, looking at the example rng_example. Now:


NRF_RNG->TASKS_START=1;
...
NRF_RNG->EVENTS_VALRDY=0;
while(NRF_RNG->EVENTS_VALRDY==0) {}

Just waits for ever?

Alan

Parents
  • Hi,

    I can get a random number by using RNG with following code.

    // sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, softdevice_assertion_handler); for (;;) { NRF_RNG->EVENTS_VALRDY = 0; NRF_RNG->TASKS_START = 1; while(NRF_RNG->EVENTS_VALRDY==0) {} u8_randNum = (u8)NRF_RNG->VALUE; }

    However, It seems stuck with NRF_RNG register accessing when sd_softdevice_enable is called in the program beginning.

    Thanks for help. Stanley

Reply
  • Hi,

    I can get a random number by using RNG with following code.

    // sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, softdevice_assertion_handler); for (;;) { NRF_RNG->EVENTS_VALRDY = 0; NRF_RNG->TASKS_START = 1; while(NRF_RNG->EVENTS_VALRDY==0) {} u8_randNum = (u8)NRF_RNG->VALUE; }

    However, It seems stuck with NRF_RNG register accessing when sd_softdevice_enable is called in the program beginning.

    Thanks for help. Stanley

Children
Related