Bluetooth code not working with LF-clock = RC-oscillator.

Getting even the simplest Bluetooth samples to work on our custom boards seem to be difficult. 

The 'Beacon' sample has no dependencies on buttons or LEDs - 

and in *theory SHOULD* work if I set target=nrf52840dk (in VScode's NRFConnect plugin, build-dialogue).

 The *only* difference is that our custom board has *no 32kHz XTAL*, so we instead use internal RC-osc.

Thus, I set these symbols in "prj.conf" (but nothing else from the sample's original config):

<<

CONFIG_CLOCK_CONTROL=y
CONFIG_CLOCK_CONTROL_NRF=y

CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y

CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y

CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=n

>>

However, this ends up in a hardfault - triggered from 'mpsl_init' it seems.

But strangely, this happens *AFTER* this code is taken (at least I can step over it):

<<

err = bt_enable(bt_ready);

>>

err = 0 after line taken.

But, as soon as I let the debugger continue (there is just a 'return 0' afterwards, so only kernel-threads running)

the CPU hangs at 'k_sys_fatal_error_handler()'.

Is this a configuration-related problem? If yes, what other symbols must be set/unset?? Is using internal RC-osc for LCclock NOT recommended at all when using BT/BLE???

Nordic documentation is vague or non-existent when it comes to 32kHz RC-osc usage restrictions.

NOTE;: I have tried to set these symbols as well - but to no avail:

<<

CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION=y
CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_LF_ALWAYS_ON=y
CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_PERIOD=8000

>>

  • Hi,

    That is expected, and matches that the HFXO clock is not started due to a HW issue.

  • OK, thanks - apparently, I have been using HFINT-clock for I2S/UART/SPI peripherals without noticing. For reference; is there any config-options that enables HFXO *directly*, or must this be configured via code/clock-API ??

  • A few drivers will start the HFXO via the clock control API (which you also used with the snippet from earlier in this thread), but there is no generic config that states that the HFXO shoudl always be used for periptherals that use the high-frequency clock. So if you need to request the HFXO when you need it, and release it when you are done (this is important for low power operation, as if not, it will continue to run even if it is not in use).

  • Okay, so now I have a board that *seem to have working HFXO connection*.

    I makes its way through the DO-WHILE loop, indicating that clock really has started.

    However, it ends in crash&burn just a little later:

    <<

     *** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
    Starting Beacon Demo
    Clock has started
    ALIVE: 0
    ALIVE: 0
    ALIVE: 0
    ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:331
            command opcode 0x0c03 timeout with err -11
    [00:00:10.000,610] <err> os: r0/a1:  0x00000003  r1/a2:  0x00000003  r2/a3:  0x00000002
    [00:00:10.000,640] <err> os: r3/a4:  0x0000014b r12/ip:  0x00000004 r14/lr:  0x00003bed
    [00:00:10.000,640] <err> os:  xpsr:  0x41000000
    [00:00:10.000,640] <err> os: Faulting instruction address (r15/pc): 0x00003bf8
    [00:00:10.000,671] <err> os: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
    [00:00:10.000,732] <err> os: Current thread: 0x20001158 (sysworkq)
    ÿ00:00:10.057,830] <err> fatal_error: Resetting system

    >>

    Continuing like this w. Reset-cycles yielding same output as above:

    If opcode consist of a group-field in upper 6 bits (of 16-bit value) then the OGF-value=0x03 - which translates to ??? (baseband group?)

  • Update: I think you can forget about errors reported on console log above. I had additional config symbols for our custom board - now investigating what should be taken out (but of course, if you find something obvious  in the console log feel free to comment on it). Going back to the NRF52840DK-build, running it I can successfully read EddystoneURL(=http://www.zephyrproject.org) from our board.

    Conclusion: we have a shaky HF-XTAL design on our board, or something's gone wrong during assembly.

    If you have no further comments, you may close the case. Thanks again for all help!Thumbsup

Related