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

NRF52 BLE examples not working with gcc

After working with NRF51822, I decided to go for NRF52832, and I bought some modules that have NRF52. I am using GCC and SDK13. I installed the S132 soft device which is in "sdk13\components\softdevice\s132\hex" using NRFGo. Then, I compiled and tested the blink example which is in "blinky\pca10040\s132", and it worked perfectly. However, none of BLE examples don't work at all. I tested many samples like "ble_peripheral\ble_app_beacon". However, the device doesn't advertise. I've done all the necessary things completely. Even the blinky example works, and I don't know why BLE examples are not working. Please, help me

This is the module that I am using image description

Parents
  • Hi,

    Assuming that the board don't have a LFCLK crystal oscillator, you will need to use the LFCLK RC oscillator. For SDK 13 you can change this in ble_stack_init()

    Code snippet:

    static void ble_stack_init(void)
    {
        ret_code_t err_code;
    
        nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
        clock_lf_cfg.source = NRF_CLOCK_LF_SRC_RC;
        clock_lf_cfg.rc_ctiv = 32;
        clock_lf_cfg.rc_temp_ctiv = 2;
            
    
        // Initialize the SoftDevice handler module.
        SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
        .
        .
        .
    
Reply
  • Hi,

    Assuming that the board don't have a LFCLK crystal oscillator, you will need to use the LFCLK RC oscillator. For SDK 13 you can change this in ble_stack_init()

    Code snippet:

    static void ble_stack_init(void)
    {
        ret_code_t err_code;
    
        nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
        clock_lf_cfg.source = NRF_CLOCK_LF_SRC_RC;
        clock_lf_cfg.rc_ctiv = 32;
        clock_lf_cfg.rc_temp_ctiv = 2;
            
    
        // Initialize the SoftDevice handler module.
        SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
        .
        .
        .
    
Children
  • Actually, I bought this module from a website in China and the only resource that I have is the photo. It seems that the module has a crystal on it which can be seen in the photo. I don't know whether is it for LF or anything else. It is true that the examples are meant for Devkits, however, I believe they are actually for the NRF52832 IC and not the Dev Kits so that with some modification they can work with any module. it seems that the module has all the necessary components because I was able to run the Blinky example. I inserted the codes for using LFCLK RC oscillator and the result is the same and I don't get anything from the device. I will go for another DevKit, however, the problem remains a mystery for me. RTT connects to the device. But it just connects and I don't get any debugging from it.

    image description

  • It seems that the module has a crystal on it which can be seen in the photo. I don't know whether is it for LF or anything else

    From the picture it looks like it only have a 32MHz HF crystal, not a LF 32 KHz crystal. The ble_app_beacon example will not output anything on the RTT by default. You will need to enable the nrf_log for that. I.e. set NRF_LOG_ENABLED to 1 , and set NRF_LOG_BACKEND_SERIAL_USES_UART to 0 and NRF_LOG_BACKEND_SERIAL_USES_RTT to 1, in sdk_config.h

    Did you see any BLE activity with nRFConnect after the code change(to use RC oscillator) with the ble_app_beacon example?

    For development I would recommend buying a nRF52-DK. The board also have a on-board Segger J-Link programmer/debugger.

  • Hi mweger,

    in SDK 14, the SoftDevice clock source settings have been moved to sdk_config.h.

    Please look for NRF_SDH_CLOCK_LF_SRC, NRF_SDH_CLOCK_LF_RC_CTIV and NRF_SDH_CLOCK_LF_RC_TEMP_CTIV in sdk_config.h

  • Hello Sigurd , Thank you for the quick response. I have tried this on the nrf52832 dev board with the 32khz xtal physically removed. It seems to hang on boot. I'm ordering another dev board in case this one has been damaged. But it seems to run fine with the other non ble examples.

Related