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

nRF8122 hangs on SOFTDEVICE_HANDLER_INIT - possible clock issue?

After beating my head against the toolchain for quite a while, I finally managed to get SES to compile the ble_app_uart for the nRF51822 using the s130 soft device. It works as expected with the development kit board (most recent PCA10028 - purchased 7/2018). The device advertises Nordic_UART, and I can find and connect to the service from LightBlue.

However, when I install the same code on my target platform, it fails silently, hanging at the call to SOFTDEVICE_HANDLER_INIT. My assumption was that this was caused by a difference between the clock on the DK board and the clock on the target, so I simply passed NULL to the SOFTDEVICE_HANDLER_INIT call. According to the documentation:

Low frequency clock source and accuracy. If NULL the clock will be configured as an rc source with rc_ctiv = 16 and .rc_temp_ctiv = 2 In the case of XTAL source, the PPM accuracy of the chosen clock source must be greater than or equal to the actual characteristics of your XTAL clock. 

Making that change (null clock parameter) fixed the hang, but did not fix the problem - the board never advertises the UART service. I assume that I need to do something to enable the internal RC clock. Any suggestions on getting it working? Most of the posts I found made reference to using something like: NRF_CLOCK_LFCLKSRC_RC_250_PPM_8000MS_CALIBRATION - but that no longer seems to be part of the SDK (I'm using 12.3). Argh...

The target is a custom board with a module from Nordic's list of module vendors. (Here's a link: https://fccid.io/2AA72-PTR5518/User-Manual/User-Manual-2123475) It claims to have a 32 kHz, 25 PPM clock, but this post makes me suspect that claim.

  • Ah, it was the clock. I'm not sure how to get the hardware clock that supposedly exists to work, but I was able to get the RC working. The SDK has changed quite a bit since the days of NRF_CLOCK_LFCLKSRC_RC_250_PPM_8000MS_CALIBRATION. The new way of setting the clock source is to edit the NRF_CLOCK_LFCLKSRC definition to use the RC:

    In pca10028.h:

    // Low frequency clock source to be used by the SoftDevice
    #ifdef S210
    #define NRF_CLOCK_LFCLKSRC      NRF_CLOCK_LFCLKSRC_XTAL_20_PPM
    #else
    #define NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_RC,            \
                                     .rc_ctiv       = 16,                             \
                                     .rc_temp_ctiv  = 2,                              \
                                     .xtal_accuracy = 0}
    #endif

    That got it working. Advertised service shows up as expected. I'm going to mark this as an answer, but I would love to know if anyone else has been able to get the crystal on the PTR5188 module working.

  • Thanks ssokol for sharing your experience!. I'm currently working with the Adafruit Uart Friend Module https://www.adafruit.com/product/2479. Just like you, I spent a lot trying to figure out what was wrong with the programming process. Your solution worked for me perfectly.

Related