Hi Sir: I written below code according to example code. In timeslot, rng will start with "rng_start_bv ". Then the process will wait until "rng_ready"==1. But, it can't work. The process will stop at "nrf_rng_error_correction_enable();" Please help !! Thanks a lot
volatile uint8_t rng_value;
volatile bool rng_enable_bv;
volatile bool rng_ready;
void rng_stop_bv(void)
{
nrf_rng_int_disable(NRF_RNG_INT_VALRDY_MASK);
nrf_rng_task_set(NRF_RNG_TASKS_STOP);
nrf_drv_common_irq_disable(RNG_IRQn);
rng_enable_bv=0;
}
void rng_start_bv(void)
{
nrf_rng_error_correction_enable();
nrf_drv_common_irq_enable(RNG_IRQn, RNG_CONFIG_IRQ_PRIORITY);
nrf_rng_shorts_clear(NRF_RNG_SHORTS_VALRDY_STOP_MASK);
nrf_rng_event_clear(NRF_RNG_EVENTS_VALRDY);
nrf_rng_int_enable(NRF_RNG_INT_VALRDY_MASK);
nrf_rng_task_set(NRF_RNG_TASKS_START);
rng_enable_bv=1;
rng_ready=false;
}
void RNG_IRQHandler(void)
{
if (rng_enable_bv)
{
if (nrf_rng_event_get(NRF_RNG_EVENTS_VALRDY) &&
nrf_rng_int_get(NRF_RNG_INT_VALRDY_MASK))
{
nrf_rng_event_clear(NRF_RNG_EVENTS_VALRDY);
rng_value=nrf_rng_random_value_get();
rng_ready=true;
rng_stop_bv();
}
}
}