This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

rng in timeslot

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();
      }
    }
}
  • It does not seem correct that it stops in nrf_rng_error_correction_enable. Please try again by remove optimizations while debugging in Keil and let us know exactly where it fails and with what error.

  • I removed the optimized in IAR. But, the situation is same. When i call the "NRF_RNG->CONFIG |= RNG_CONFIG_DERCEN_Msk;",the program will lack in "HardFault_Handler". I am using rng in timeslot callback with S110. Do i need to use the SOC API instead of calling rng driver? ex:"sd_rand_application_vector_get ", do you help to give a simple example? thanks a lot

  • This is news to me, seems like Timeslot does not allow the use of RNG. below is copy paste from S110 SDS

    When a timeslot is granted, the application has exclusive and realtime access to the normally blocked RADIO, TIMER0, CCM, AAR, and PPI (channels 14 – 15) peripherals 
    

    Looks like RNG is still protected, you can fix this for now by using SOC API for accessing RNG. I will go to work tomorrow and dig for some internal details of this behavior.

Related