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

softdevice_handler_int, never returns.

I'm a newbie so bare with me. I had this code running, saved it, and started another project. I tried not to touch any of the files I had running with the example below, but somewhere along the line I messed something up.

I needed to run this code today so I loaded itinto the eval board, expecting it to run just fine. The build ran without any errors or warnings. However the code hangs when I make a call to softdevice_handler_int

do                                                                                            
    {                                                                                              
        static uint32_t EVT_BUFFER[CEIL_DIV(MAX(                                                   
                                                MAX(BLE_STACK_EVT_MSG_BUF_SIZE,                    
                                                    ANT_STACK_EVT_STRUCT_SIZE),                    
                                                SYS_EVT_MSG_BUF_SIZE                               
                                               ),                                                  
                                            sizeof(uint32_t))];                                    
        uint32_t ERR_CODE;                                                                         
        ERR_CODE = softdevice_handler_init((NRF_CLOCK_LFCLKSRC_XTAL_20_PPM),                                         
                                           EVT_BUFFER,                                             
                                           sizeof(EVT_BUFFER),                                     
                                           (false) ? softdevice_evt_schedule : NULL);      
        APP_ERROR_CHECK(ERR_CODE);                                                                 
    } while (0);

Softdivice_handler_init ends up in arm_startup_nrf51.s line 156

SVC_Handler     PROC
                EXPORT  SVC_Handler               [WEAK]
                B       .
                ENDP
  • what did I change? How do I get the Softdecive to initialize?

Thanks, Clint

  • That it hangs in the softdevice_handler_init() should indicate that it is waiting for the clock source chosen to come become ready/available. I see you're inputting the LFCLK source in the seoftdevice_handler.h file. You should instead input this in ble_stack_init() in main.

    static void ble_stack_init(void) {
        uint32_t err_code;
    
        // Initialize the SoftDevice handler module.
        SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);
    

    Also, make sure you are using the same softdevice as you were using initially. There's been some changes in the ble_stack_init() between S110 v6.0 and S110 v7.0. But if that was the cause of this, you would have gotten stuck on the line after the softdevice_handler_init(). So check you clock source that it's available and that it is running. You could also try using the internal 32 kHz RCOSC by inputting NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION instead of NRF_CLOCK_LFCLKSRC_XTAL_20_PPM like below here.

    static void ble_stack_init(void)
    {
        uint32_t err_code;
    
        // Initialize the SoftDevice handler module.
        SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, false);
    
Related