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

Can not enable Softdevice with nRF52 Preview DK

Hi,

I am trying to get my mesh running on the nRF52 Preview DK but calling

SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL);

will break my program. If I leave the Softdevice disabled, the rest of my code runs okay while constantly complaining, that the Softdevice is not enabled.

The debugger runs until it reaches the line with sd_softdevice_enable and then jumps to the Hardfault handler. How would I go on about debugging this? Is there an Errata that I am missing?

Thanks, Marius


I am using this GCC setup if that helps...: embeddedsoftdev.blogspot.de/.../ehal-nrf51.html

  • Hi

    Code stuck in SOFTDEVICE_HANDLER_INIT() usually indicates a faulty low frequency crystal. To see if this is an issue try to write:

    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_SYNTH_250_PPM, NULL);
    

    instead to synthesize a low frequency clock from the 16MHz crystal. You can also try to start the LFCLK manually and check whether it starts or not.

    It can also be a SDK/Softdevice incompatibility. Have you set your RAM and ROM addresses in "Target Options -> Target" so that they match your Softdevice?

  • Hi,

    thanks. I've tryed to start the clock with the synthesized source but did not notice any difference. Then, I used the following code to start up the low frequency clock:

    //Try to start Low frequency clock manually
    NRF_CLOCK->LFCLKSRC = NRF_CLOCK_LFCLKSRC_XTAL_20_PPM;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    
    u32 a = 0;
    while(true){
    	while(a < 10000000){
    		a++;
    	}
    	logt("ERROR", "running? %d", NRF_CLOCK->LFCLKSTAT);
    	if(NRF_CLOCK->LFCLKSTAT != 0){
    		logt("ERROR", "continue");
    		break;
    	}
    }
    

    But this did not help either. The low frequency clock starts successfully after some time (65536: indicating that is is started and that it is using the RC source).

    Maybe this is the GCC ssetup that I am using where I had to change line 56 in the nrf_svc.h to:

            "bx r14" : : "I" ((uint16_t)number) : "r0" \
    

    to compile it. Maybe this is jumping to the wrong address.

  • According to my debugger, the program first executes the call:

    svc 16
    

    which makes the processor jump to address 0x860. Would that be the correct address or is there something wrong?

  • That's the right address. Are you building with floating point enabled? There's code in SystemInit which enables the FP unit if so, ensure it's being compiled in (lines 83 to 87 of system_nrf52.c). The current softdevice erroneously requires the FP unit to be enabled.

  • Thanks a lot, that was the right hint. I've enabled floating point ABI support for my project which caused the linker to complain because the CMSIS library that I am using was not compiled with FPU support. I recompiled that library with FPU support and my mesh as well. I had a wrong include as well, which I just fixed. The result is just great.

    My mesh seems to be working flawlessly with the nRF52 DK and some nRF51 Dongles. Didn't expect it to be that easy.....

Related