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

ANT+ sd_ant_channel_close reseting

Hi,

We are using nrf52832 for ANT and BLE for which we use SDK_17.0.2 and s332_nrf52_7.0.1

Our objective is to pair and un-pair ANT sensors. So far pairing multiple ANT sensors and snding the data via BLE works fine. But when we do try to un-pair sensors by closing the channel, the device does restarts.

For that we did try to use sd_ant_channel_close() function. We did use it in our event and in main while loop with a dalay as well. We did try with sd_ant_channel_unassign() function after closing the channel as well.

Is there some sequence that we are missing? Below is our channel init code. Thank you.

static void ANT_profile_HRM_setup(uint8_t ant_channel_no, uint32_t ant_device_no)
{
/** @snippet [ANT HRM RX Profile Setup] */
       
    uint32_t err_code = sd_ant_lib_config_set(ANT_LIB_CONFIG_MESG_OUT_INC_DEVICE_ID);
    APP_ERROR_CHECK(err_code);

        ant_channel_config_t channel_config =
    {
        .channel_number     = ant_channel_no,
        .channel_type       = CHANNEL_TYPE_SLAVE,
        .ext_assign         = HRM_EXT_ASSIGN,
        .rf_freq            = HRM_ANTPLUS_RF_FREQ,
        .transmission_type  = CHAN_ID_TRANS_TYPE,
        .device_type        = HRM_DEVICE_TYPE,
        .device_number      = ant_device_no,
        .channel_period     = HRM_MSG_PERIOD_1Hz,
        .network_number     = ANTPLUS_NETWORK_NUM,
    };

    const ant_search_config_t ant_search_config =
    {
        .channel_number        = ant_channel_no,
        .low_priority_timeout  = ANT_LOW_PRIORITY_TIMEOUT_DISABLE,
        .high_priority_timeout = ANT_HIGH_PRIORITY_SEARCH_DISABLE,
        .search_sharing_cycles = ANT_SEARCH_SHARING_CYCLES_DISABLE,
        .search_priority       = ANT_SEARCH_PRIORITY_DEFAULT,
        .waveform              = ANT_WAVEFORM_DEFAULT,
    };


    err_code = ant_hrm_disp_init(&m_ant_hrm, &channel_config, ant_tmp_evt_handler);
    APP_ERROR_CHECK(err_code);

        // Set search timeout
        err_code = ant_search_init(&ant_search_config);
        APP_ERROR_CHECK(err_code);

    err_code = sd_ant_channel_open(ant_channel_no);
    APP_ERROR_CHECK(err_code);


    err_code = ant_state_indicator_channel_opened();
    APP_ERROR_CHECK(err_code);

/** @snippet [ANT HRM RX Profile Setup] */
}

Best regards, Ram

  • But when we do try to un-pair sensors by closing the channel, the device does restarts.

    This means you likely have an assert, it will default do a soft reset if any api call return an error code. If you build with DEBUG (not RELEASE) then you should fint the actual error code, line number and file name causing the error in app_error_fault_handler(). Can you provide this information? 

    Thanks,
    Kenneth

  • Sorry, I should send that earlier.It stops in:

    nRF5_SDK_17.0.2_d674dde\components\libraries\log\src\nrf_log_frontend.c in line 999 (nrf_log_backend_enable(p_backend);)

    void nrf_log_panic(void)
    {
        nrf_log_backend_t const * p_backend = m_log_data.p_backend_head;
        m_log_data.autoflush = true;
        while (p_backend)
        {
            nrf_log_backend_enable(p_backend);
            nrf_log_backend_panic_set(p_backend);
            p_backend = p_backend->p_cb->p_next;
        }
    }

    Does that help?

  • Are you sure you have init NRF_LOG()? Does nrf_log work in your application before you end up in app_error_fault_handler()?

    In any case you should be able to comment out NRF_LOG_FINAL_FLUSH() if you want and set a breakpoint in NRF_FAULT_ID_SDK_ERROR switch case to get the information you want to (file name, error code and line number) if you have the debugger attached.

    Kenneth

  • Hi Kenneth;

    I was mising log_init() sorry. Ok now I have downloaded clean SDK_17.0.2 and s212_7.0.1 to make sure there isn't any of my code inside.

    - I have tested ANT HRM TX and RX example on 2 PCA10040 evaluation boards, and I do get the data over the serial terminal

    - I have added sd_ant_channel_close(HRM_CHANNEL_NUM); and it stops in HRM RX or TX example

    Code in main loop looks like:

    int main(void)
    {
        log_init();
        utils_setup();
        softdevice_setup();
        profile_setup();
    
        NRF_LOG_INFO("ANT+ Heart Rate RX example started.");
    
        for (;;)
        {
    
            if ( channel_flag_1 == 0)
            {
                ant_close_channel();
                channel_flag_1 = 1;
            }
    
            counter_1++;
    
    //        NRF_LOG_FLUSH();
    //        nrf_pwr_mgmt_run();
        }
    }

    ant_close_channel(); function is in ant_hrm.c just like other initialisations and contains only sd_ant_channel_close(HRM_CHANNEL_NUM);

    -This is only change in example code

    - In debug (not release) mode the code is running without restarting (before in my own code it did restart - because log_init() was missing I think)

    - It does pass ant_close_channel(); because 32-bit unsigned variable counter_1 does increase to around 9000. But then it stops. As well when trying it for few times, the counter variable is never exactly same value when it stops

    - When pressing pause in debugging it always stops in nrfx_uart.c and nrfx_uart.h (attached images), it looks like it is looping

    - After that I have commented NRF_LOG_FINAL_FLUSH() and set breakpoint at switch (id)

    - "id" variable is 0x00004002 so I do end up in NRF_FAULT_ID_SDK_ASSERT

    Is the sequence of how I am using sd_ant_channel_close incorrect?

  • Can you send me a modified nRF5 SDK example that I can run on an nRF52-DK, where the only change you do is to add sd_ant_channel_close() so I can see the example? I am very baffled that you are not getting a proper fault handler here.

    Kenneth

     

Related