ANT on PCA10056 and custom board ?

Dear Members,

I want to run ANT+ code in my custom board,

It works well on PCA10056, I can upload softdevice and the code to custom board board,

but I didn't get any responses,

I have tried with code without softdevice, the custom board works well

Any ideas ?

Thanks

Parents
  • Hello,

    Does your custom board have a 32KHz crystal mounted? If not, you have to make sure you select the internal RC oscillator when you enable the Softdevice. Otherwise, the Softdevice will enter an infinite loop waiting for the crystal to start.

    The memory layout should be left as is.

    Best regards,

    Vidar

  • Does softdevice require VDD HV? I connected VDD HV to 3.3V .

  • I have tried every option for softdevice clock, and no avail yet

  • Did you add the ble_stack_init(); yourself? I don't see ble_stack_init() being called from softdevice_setup() in the SDK example.

  • there are two softdevice_setup function I can see,

    one in the main

    /**@brief Function for ANT stack initialization.
     *
     * @details Initializes the SoftDevice and the ANT event interrupt.
     */
    static void softdevice_setup(void)
    {
          NRF_LOG_INFO("softdevice_setup\r\n");
        ret_code_t err_code = nrf_sdh_enable_request();
        APP_ERROR_CHECK(err_code);

        ASSERT(nrf_sdh_is_enabled());

        err_code = nrf_sdh_ant_enable();
        APP_ERROR_CHECK(err_code);

        err_code = ant_plus_key_set(ANTPLUS_NETWORK_NUM);
        APP_ERROR_CHECK(err_code);
    }

    and one in asc_coordinator.c

    /**@brief BLE + ANT stack initialization.
     *
     * @details Initializes the SoftDevice and the stack event interrupt.
     */
    static void softdevice_setup(void)
    {
        ret_code_t err_code = nrf_sdh_enable_request();
        APP_ERROR_CHECK(err_code);
        NRF_LOG_INFO("softdevice_setup\r\n");
        ASSERT(nrf_sdh_is_enabled());

    #ifdef BLE_STACK_SUPPORT_REQD
        ble_stack_init();
    #endif

        err_code = nrf_sdh_ant_enable();
        APP_ERROR_CHECK(err_code);

        // Register a handler for ANT events.
        NRF_SDH_ANT_OBSERVER(m_ant_observer, APP_ANT_OBSERVER_PRIO, ant_evt_handler, NULL);
        
          
    }

    I got these error on debug


    nfo> app_timer: RTC: initialized.
                                                


                                   


                                                                                 

    nfo> app: utils_setup
                                                            


                                                                                 

    rror> app: Fatal error
                                                           

    arning> app: System reset
                                                        

    nfo> app: log_init.

    in the main()

    ....

    log_init();
        utils_setup();
          APP_ERROR_CHECK(err_code);
        softdevice_setup();
          APP_ERROR_CHECK(err_code);

    ....
                                                              


                           

  • without APP_ERROR_CHECK :


    nfo> app_timer: RTC: initialized.
                                                


    fo> app: Rixtronix LAB. SP_BUTTON_ACTION_PUSH
                                   

                                                                                  


    fo> app: Rixtronix LAB. SP_BUTTON_ACTION_PUSH
                                   

                                                                                  


    fo> app: Rixtronix LAB. SP_BUTTON_ACTION_PUSH
                                   

                                                                                  


    fo> app: Rixtronix LAB. SP_BUTTON_ACTION_PUSH
                                   

                                                                                  


    fo> app: utils_setup
                                                            

                                                                                  


    fo> app: softdevice_setup main
       

    and stopped

  • stopped at this function :

    ret_code_t err_code = nrf_sdh_enable_request();

    How can I check my 32KHz crystal running ?

Reply Children
  • No matter I used 0, 1 or 2

    // <0=> NRF_CLOCK_LF_SRC_RC
    // <1=> NRF_CLOCK_LF_SRC_XTAL
    // <2=> NRF_CLOCK_LF_SRC_SYNTH

    #ifndef NRF_SDH_CLOCK_LF_SRC
    #define NRF_SDH_CLOCK_LF_SRC 1

    it's still stopped on

    ret_code_t err_code = nrf_sdh_enable_request();

  • RixtronixLAB said:
    without APP_ERROR_CHECK :

    Which APP_ERROR_CHECK? The one after nrf_sdh_enable_request()? Also, os nrf_sdh_enable_request() called from ble_stack_init() as well, or only from softdevice_setup()?

    RixtronixLAB said:
    How can I check my 32KHz crystal running ?

    If you have selected the crystal, then it will be running once the nrf_sdh_enable_request() function has returned  with NRF_SUCCESS.

  • Hi Vidar, thanks for the reply

    Yes, The one after nrf_sdh_enable_request(),

    The running softdevice_setup is

    /**@brief Function for ANT stack initialization.
     *
     * @details Initializes the SoftDevice and the ANT event interrupt.
     */
    static void softdevice_setup(void)
    {
          NRF_LOG_INFO("softdevice_setup main\r\n");
        ret_code_t err_code = nrf_sdh_enable_request();
          APP_ERROR_CHECK(err_code);
        ASSERT(nrf_sdh_is_enabled());
    
        err_code = nrf_sdh_ant_enable();
        APP_ERROR_CHECK(err_code);
          NRF_LOG_INFO("softdevice_setup sdh_enable\r\n");
    
        err_code = ant_plus_key_set(ANTPLUS_NETWORK_NUM);
        APP_ERROR_CHECK(err_code);
          NRF_LOG_INFO("ant_plus_key\r\n");
    }

    Debug out :

    fo> app: log_init.
    nfo> app_timer: RTC: initialized.
    fo> app: Rixtronix LAB. SP_BUTTON_ACTION_PUSH
    fo> app: Rixtronix LAB. SP_BUTTON_ACTION_PUSH
    fo> app: Rixtronix LAB. SP_BUTTON_ACTION_PUSH
    fo> app: Rixtronix LAB. SP_BUTTON_ACTION_PUSH
    fo> app: utils_setup
    fo> app: softdevice_setup main
    fo> nrf_sdh: nrf_sdh_enable_request
    fo> nrf_sdh: CRITICAL_REGION_ENTER

    Stop until this line :

     CRITICAL_REGION_ENTER();
             NRF_LOG_INFO("CRITICAL_REGION_ENTER\r\n");

    at Line 211

    E:\nRF5_SDK_17.0.2_d674dde\components\softdevice\common\nrf_sdh.c

    is it possible that my XL1 and XL2 pad on 32KHz not soldered properly, causing this error ?

    How can I use RC oscillator for running softdevice in debug mode ?

    it ended up in this line :

    /** @addtogroup NRF_SDM_FUNCTIONS Functions
     * @{ */
    
    /**@brief Enables the SoftDevice and by extension the protocol stack.
     *
     * @note Some care must be taken if a low frequency clock source is already running when calling this function:
     *       If the LF clock has a different source then the one currently running, it will be stopped. Then, the new
     *       clock source will be started.
     *
     * @note This function has no effect when returning with an error.
     *
     * @post If return code is ::NRF_SUCCESS
     *       - SoC library and protocol stack APIs are made available.
     *       - A portion of RAM will be unavailable (see relevant SDS documentation).
     *       - Some peripherals will be unavailable or available only through the SoC API (see relevant SDS documentation).
     *       - Interrupts will not arrive from protected peripherals or interrupts.
     *       - nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for reliable usage of the SoftDevice.
     *       - Interrupt latency may be affected by the SoftDevice  (see relevant SDS documentation).
     *       - Chosen low frequency clock source will be running.
     *
     * @param p_clock_lf_cfg 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.
     * @param fault_handler Callback to be invoked in case of fault, cannot be NULL.
     * @param p_license_key License key for ANT based softdevices. NULL can be used for BLE only softdevices. See ANT_LICENSE_KEY define for more detail.
     *
     * @retval ::NRF_SUCCESS
     * @retval ::NRF_ERROR_INVALID_ADDR  Invalid or NULL pointer supplied.
     * @retval ::NRF_ERROR_INVALID_STATE SoftDevice is already enabled, and the clock source and fault handler cannot be updated.
     * @retval ::NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDevice interrupt is already enabled, or an enabled interrupt has an illegal priority level.
     * @retval ::NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN Unknown low frequency clock source selected.
     * @retval ::NRF_ERROR_INVALID_LICENSE_KEY Incorrect ANT license key. See ANT_LICENSE_KEY define for more detail.
     * @retval ::NRF_ERROR_INVALID_PARAM Invalid clock source configuration supplied in p_clock_lf_cfg.
     */
    SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t, sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, nrf_fault_handler_t fault_handler, const char* p_license_key));
    

    SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t, sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, nrf_fault_handler_t fault_handler, const char* p_license_key));

    E:\nRF5_SDK_17.0.2_d674dde\components\softdevice\SoftDevice\headers\include\nrf_sdm.h Line 337

    How can I debug it (in which line) I put breakpoint ?

    Await for your reply, thanks.

  • Debug and breakpoint screen shot :

    Any clues ?

    LFCLK Not Running

  • The program will not return from nrf_sdh_enable_request() unless the crystal oscillator has started, and you said earlier it did return. So it should not be an issue with the crystal not starting up. However, if you still suspect the 32KHz crystal to be the culprit, then you try to select the NRF_CLOCK_LF_SRC_SYNTH  source.

    Can you print out the return value from nrf_sdh_enable_request()?

Related