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

After calling sd_softdevice_enable then SystemReset. Why?

I use the SDK v11.0 alpha, the S130 with my USB-dongle(NRF51422).

I use the low_power_pwm to initialize 4 different PWMs. I used the Example low_power_pwm_s130_pca10031 and just added one PWM. It worked fine.

Then i took the ble_app_hrs_c_s130_pca10031 Example added the 4 PWMs. Now i get a SystemReset when i call the sd_softdevice_enable function and get the err_code NRF_ERROR_INVALID_STATE.

Why i can't enable the softdevice?

int main(void){
bool erase_bonds;
	
// Initialize.
SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);			//ADDED by Pechi
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);		//ADDED by Pechi
low_power_init();														//ADDED by Pechi Init of 4 PWMs

buttons_leds_init(&erase_bonds);
nrf_log_init();
ble_stack_init();					//!Here! SystemReSet after calling sd_softdevice_enable
device_manager_init(erase_bonds);
db_discovery_init();
hrs_c_init();
bas_c_init();
	
// Start scanning for peripherals and initiate connection
// with devices that advertise Heart Rate UUID.
scan_start();
	
for (;; )
{
    power_manage();
}
Parents
  • So you know what the error code is, it's NRF_ERROR_INVALID_STATE, what does the documentation for sd_softdevice_enable() say about that?

    SoftDevice is already enabled, and the clock source and assertion handler cannot be updated.
    

    So the problem is the softdevice is already enabled. So where was it enabled? Since there are 3 lines you marked as ADDED by pechi it's probably going to be one of those. sd_softdevice_enable() takes a clock source as argument, so it seems does SOFTDEVICE_HANDLER_INIT() that seems rather suspicious doesn't it?

    Looking at the code to SOFTDEVICE_HANDLER_INIT() that calls softdevice_handler_init() which calls sd_softdevice_enable()

    So you've called sd_softdevice_enable() twice which the error message tells you you can't do.

Reply
  • So you know what the error code is, it's NRF_ERROR_INVALID_STATE, what does the documentation for sd_softdevice_enable() say about that?

    SoftDevice is already enabled, and the clock source and assertion handler cannot be updated.
    

    So the problem is the softdevice is already enabled. So where was it enabled? Since there are 3 lines you marked as ADDED by pechi it's probably going to be one of those. sd_softdevice_enable() takes a clock source as argument, so it seems does SOFTDEVICE_HANDLER_INIT() that seems rather suspicious doesn't it?

    Looking at the code to SOFTDEVICE_HANDLER_INIT() that calls softdevice_handler_init() which calls sd_softdevice_enable()

    So you've called sd_softdevice_enable() twice which the error message tells you you can't do.

Children
Related