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

RNG interrupt handler not called

RNG interrupt handler is not called.

Using nrfx_rng library to generate random numbers.

VALRDY event is generated but interrupt handler nrfx_rng_irq_handler in library is not called.

Breakpoint not hit.

Despite EVENTS_VALRDY being set.

and INTENSET/ NVIC_ISER0 having correct values.

Code which sets up RNG using nrfx_rng library

ren_status_t generateRand(uint8_t * p_challenge)
{
ren_status_t return_value = RAND_ERROR;

static const nrfx_rng_config_t RNG_CONFIG = {
.error_correction = true,
.interrupt_priority = RNG_INTERRUPT_PRIORITY
};

assert(p_challenge != NULL);

challenge_pointer = p_challenge;

/* Reset random number counter. */
random_number_index = 0U;

/* Initialise random number generator. */
if (NRF_SUCCESS == nrfx_rng_init(&RNG_CONFIG, randomNumberEventHandler))
{
/* Start random number generator. */
nrfx_rng_start();

/* Wait for required number of random numbers to be generated. */
while(random_number_index < RAND_SIZE);

/* Stop random number generator. */
nrfx_rng_stop();

/* Uninitialise random number generator. */
nrfx_rng_uninit();

return_value = RAND_SUCCESS;
}

return return_value;
}



static void randomNumberEventHandler(uint8_t rng_data)
{
assert(challenge_pointer != NULL);

/* Store random number in appropriate location in challenge. */
rand_pointer[random_number_index] = rng_data;

/* Move on to next location. */
random_number_index++;
}

Any ideas ?

Related