Close ANT HRM channel and save to SDcard ?

Dear Members,

How can I stop ANT HRM channel temporarily, and save the heart rate value on to SDcard ?

My code at static void page0_data_log(ant_hrm_page0_data_t const * p_page_data),

err_code = sd_ant_channel_close(HRM_CHANNEL_NUM);
APP_ERROR_CHECK(err_code);
        
        log_hrm(p_page_data->computed_heart_rate); //log HRM value 8Dec21 Rixtronix LAB
        //open the channel
        err_code=sd_ant_channel_open(HRM_CHANNEL_NUM);
        APP_ERROR_CHECK(err_code);

Please revise me ?

Thanks

Parents Reply
  • the event that indicate the channel is closed ,which event ? thanks...

    code :

     
    		err_code = sd_ant_channel_close(HRM_CHANNEL_NUM);
         APP_ERROR_CHECK(err_code);
    		
    		 if (err_code==NRF_SUCCESS )
    			 {
    				 
    		      err_code = sd_ant_channel_unassign(HRM_CHANNEL_NUM); 
    				 NRF_LOG_INFO("WRITE HRM TO SDcard Page 0...\r\n");
    		
    				 
    			 }

    Please correct me the sequence and where should I put that sequence of closing the channel, write to SDcard and reopen again ?

    Thanks

Children
  • You should receive an EVENT_CHANNEL_CLOSED event in your event handler. The easiest way to find the name of the event handler may be to search the project for NRF_SDH_ANT_OBSERVER(). It may look something like this (example taken from ant_hrm_tx):

    You may also add your own NRF_SDH_ANT_OBSERVER() if you like.

    Kenneth

  • Hi Kenneth,

    I've found that function at ant_state_indicator.c

    on this case :

      case EVENT_CHANNEL_CLOSED:
                        NRF_LOG_INFO("EVENT_CHANNEL_CLOSED...\r\n");
                        nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF); //default

    I never that get "case",

    and I have put at E:\nRF5_SDK_17.0.2_d674dde\components\ant\ant_profiles\ant_hrm\pages\ant_hrm_page_0.c

    function :

    static void page0_data_log(ant_hrm_page0_data_t const * p_page_data)

    err_code = sd_ant_channel_close(HRM_CHANNEL_NUM);

    The interrupt from HRM keeps coming and system reset

    How can I close it and reopen ?

    Thanks

  • You write system reset, the only way the chip will reset is if power is removed, pin reset is pressed or NVIC_SystemReset() is called. I believe the case here is that NVIC_SystemReset() is called, and likely from the app_error_fault_handler(), you should build with DEBUG to find the exact cause.

    Kenneth

  • Ok, I will try build and use DEBUG, anyway,

    I never got these breakpoints  :

    When it's connected on ANT HRM, it keeps running never stop on that breakpoint ?

    Any ideas ?

    Thanks

  • Hi Kenneth,

    When I put DEBUG,

    I got this :



                                                                                 

    nfo> app: Err_code libuarte_init libuarte1 0
                                     

    rror> app: SOFTDEVICE: ASSERTION FAILED

    What's the cause of "SOFTDEVICE: ASSERTION FAILED" ?

    How can we trace it ?

    Thanks
              

Related