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

Device loops on sd_softdevice_enable

I am new to Nordic, and Keil, and not especially strong in microprocessors yet. I am trying to get currently developed firmware for a nRF52382 chip to operate on a custom built board.

I submitted the following problem to the rest of my team, but I am trying to reach out and get any help I can as I am on a tight schedule. The question resides at the bottom.

I am currently operating with the pre-built s132_nrf52_2.0.1_softdevice.hex (was originally using s132_nrf52_2.0.0_softdevice.hex) soft device, because I have yet to be able to build the custom soft device from the project.

When operating at main() ble_stack_init() is called which calls: SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL); where clock_If_cfg is set at xtal_accuracy of NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM; which calls: (at line 285 on softdevice_handler.c) err_code = sd_softdevice_enable(p_clock_lf_cfg, softdevice_fault_handler); who's passed in values are the same object with xtal_accuracy NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM and second variable is NULL.

the function sd_softdevice_enable is not defined in any files, however the assembly is as follows: 0x00009076 BF20 WFE 0x00009078 F8D40104 LDR r0,[r4,#0x104] 0x0000907C 2800 CMP
r0,#0x00 0x0000907E D0FA BEQ
0x00009076

WFE (which i believe is the source of my problem) waits for an IRQ or FIQ interrupt to the system. When one is seen, it is supposed to make an immediate return, www.keil.com/.../armasm_dom1361289926047.htm

LDR loads the value in memory from address in r4 (0x40000000) with offset (0x104) into register r1. That value in memory is 0x00000000.

CMP compares register r0 with the value 0x00 which results in both being equal, resulting in the zero flag set to 1 (resulted in zero).

and BEQ finds that the zero flag is set to true and jumps the next command back up toe the WFE statement.

My suspicion is that I need to trigger an IRQ/FIQ event somehow for it to escape this loop, but I am not sure how. I'm not even sure what type of event needs to be happening, but since the function is called by handing in the p_clock_lf_cfg data, I'm assuming it is an event triggered by the clocking system. I have tried bypassing this problem by skipping over the BEQ statement, and then one more additional bypass, but after it leaves the function, pretends to act nicely, it just loops back around to this function because it didn't start properly.

Any ideas would be absolutely great. I'm not sure if it is that I need the custom softdevice working properly, or if there is something up with the clock settings, or if we need a callback function set, but I suspect it is one of those three.

So, apologies if there isn't enough detail, but any input would be appreciated.

  • It is not possible to compile the SoftDevice, it is only distributed as a precompiled hex file. sd_softdevice_enable() is a SoftDevice function, and is defined inside the SoftDevice. What SDK are you using? Are you able to use the unmodified examples in the SDK? Have you tested any other examples (without SoftDevice) on this custom board? Does your custom board have an external LF crystal? Maybe you can try by usingt he RC as a LF source instead? Try something like:

    nrf_clock_lf_cfg_t clock_lf_cfg = 
    {
        .source = NRF_CLOCK_LF_SRC_RC,
        .rc_ctiv = 16, // Interval in 0.25 s, 16 * 0.25 = 4 sec
        .rc_temp_ctiv = 2, // Check temperature every .rc_ctiv, but calibrate every .rc_temp_ctiv 
        .xtal_accuracy = 0,
    };
    
  • I believe it is the 12.2.0 SDK but I will have to check when I get to my computer tomorrow.

    Well, that makes things interesting, because some reason whoever started the project has a target for compiling a soft device, maybe I'm just understanding what is in the project wrong.

    There is supposed to be an external crystal on the board, at least I was told that there is. I'm more of a software guy so I am still learning the hardware aspects, however when I look at the board, and some of the schematics I have read, I have a hard time identifying anything that looks like the external LF crystal, I kinda don't think it is on there. I will see about using the internal clock, thanks for the info.

  • That target is only for flashing the SoftDevice through Keil I believe.

  • Is there any possible problems with flashing the softdevice through nRFgo Studio then If I use the appropriate softdevice to my Nordic chip on a custom board? Or does flashing the chip through Keil allow it to pull from files such as the custom_board.h file that I have also been trying to figure out?

  • Petter Myhre, I tried changing to the internal clock, and I could be saying this early, but I think that solved my problem. Thanks so much. I'm betting the external crystal is just not on this board. I'll post if anything changes.

Related