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

Re-enable softdevice

Hi. I'm trying to enable and disable softdevice repeatedely. In my code, softdevice is firstly enabled then advertising properly. After some seconds, softdevice is disabled and ESB is enabled. It is worked properly too. and then esb is deisabled, softdevice is re-enabled and try to start advertising. But I found an error code when re-enabling softdevice.

in ble_stack_handler.c

err_code = sd_softdevice_enable(clock_source, softdevice_assertion_handler);

returns 0x00001001 at second enabling. (at first enabling, it returns NRF_SUCCESS)

I don't know how to solve the problem. please help.

Parents
  • I had exactly the same problem: when trying to re-enable my softdevice after running ESB the sd_softdevice_enable() function would return with the "NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION" error code.

    The solution that worked for me was to disable the RADIO_IRQn interrupt in the nrf_esb_disable() function inside of the nrf_esb.c file.

    My modified nrf_esb_disable() function looks like this.

    uint32_t nrf_esb_disable(void)
    {
        m_nrf_esb_mainstate = NRF_ESB_STATE_DISABLE;
    
        /* Disable RADIO first. */
        NRF_RADIO->INTENCLR        = 0xFFFFFFFF;
        NRF_RADIO->EVENTS_DISABLED = 0;
        NRF_RADIO->TASKS_DISABLE   = 1;
        while (NRF_RADIO->EVENTS_DISABLED == 0) ;
        
        // Clear PPI
        NRF_PPI->CHENCLR = (1 << NRF_ESB_PPI_TIMER_START) |
                           (1 << NRF_ESB_PPI_TIMER_STOP)  |
                           (1 << NRF_ESB_PPI_RX_TIMEOUT)  |
                           (1 << NRF_ESB_PPI_TX_START);
    
        m_nrf_esb_mainstate = NRF_ESB_STATE_IDLE;
    
        reset_fifos();
    
        memset(m_rx_pipe_info, 0, sizeof(m_rx_pipe_info));
        memset(m_pids, 0, sizeof(m_pids));
    
        // Disable the radio
        NVIC_DisableIRQ(ESB_EVT_IRQ);
        NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Enabled << RADIO_SHORTS_READY_START_Pos |
                            RADIO_SHORTS_END_DISABLE_Enabled << RADIO_SHORTS_END_DISABLE_Pos;
    
        // EDIT JBR: return origional priorities - turns out to be unnecessary.
        NVIC_SetPriority(RADIO_IRQn, s_radio_irq_initial_priority);
        NVIC_SetPriority(ESB_EVT_IRQ, s_esb_irq_initial_priority);
        // EDIT JBR: disable the radio interrupt! this is the one that fixes it
        NVIC_DisableIRQ(RADIO_IRQn);
    
        return NRF_SUCCESS;
    }
    

    I also reset the priorities for the interrupts back to the values that they were at before the nrf_esb_init() function changed them, but that proved to be unnecessary.

  • It will probably be a few days before I have time to set up a clean example than runs on the developement boards (not my own hardware), but I will do so when I can. Perhaps the problem is that I am initializing the soft device first, disabling it when I want to use ESB, and then re-initializing it when I am done with ESB. I am using version 11.0.0 of the sdk and the s132 softdevice, but I tried it with version 12.0.0 well and had the same problem.

    I did make one other change to the nrf_esb.h file so that I could use the app_timer module. see this link.

    I will post thins kind of stuff as a comment in the future.

Reply
  • It will probably be a few days before I have time to set up a clean example than runs on the developement boards (not my own hardware), but I will do so when I can. Perhaps the problem is that I am initializing the soft device first, disabling it when I want to use ESB, and then re-initializing it when I am done with ESB. I am using version 11.0.0 of the sdk and the s132 softdevice, but I tried it with version 12.0.0 well and had the same problem.

    I did make one other change to the nrf_esb.h file so that I could use the app_timer module. see this link.

    I will post thins kind of stuff as a comment in the future.

Children
No Data
Related