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.

  • I am using ble_app_gzll for my refernce example, but the problem does not solved.

  • Hi,

    Error code 0x00001001 means "NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDeviceinterrupt is already enabled". See the description of sd_softdevice_enable.

    Have you made sure you have disabled it before you enable it again ?

    When you testing with our ble_app_gzll do you have the same issue ?

  • Hi. I used ble_conn_params_stop() and softdevice_handler_sd_disable(), as in ble_app_gzll. I didn't check the return values of sd_softdevice_enable() in the ble_app_gzll yet.

    And, ble_app_evt_wait() function returns 0x02 that means soft device is not enabled. (devzone.nordicsemi.com/.../) If the softdevice is already enabled, why the function ble_app_wait_evt() returns 0x02?

    So I think the error code 0x00001001 means "enabled interrupt has an illegal priority level". How can I check priority level of enabled interrupts?

  • @LKH: You can get the priority level by using NVIC_GetPriority or sd_nvic_GetPriority() when softdevice is enabled. Make sure you don't use interrupt priority level 0 or 2 in your application when starting softdevice.

    I would suggest you to test by not enabling any other interrupt /code when disable and enable the softdevice. (follow what we did in ble_app_gzll). And then gradually add your code in and see when the issue happens.

  • 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.

Related