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

ANT+ pre-event timing

Hi,

I have a simple question. How should I handle situation, when need to collect data and process them before the computed data are sended via ANT+ profile which runs on 4Hz update rate? I had an idea to use repeated timer, but it is not possible, because for example when I set timer interval to 240ms to have 10ms for data processing before they are sended, the gap between data processing is getting bigger in time. Acceptable would be if the data processing would be handled 10-20ms before ANT+ data send event every time. So please, any suggestion, what should I do?

thanks,

Pepam

Parents
  • You should check out Radio Notification in the Softdevice Specifications. This is a callback that the softdevice can provide to the application a fixed time before an Radio event (for instance ANT data) occurs. In the nRF5 SDK I believe you should find ble_radio_notification.c that can do this for you already, it will will work for ANT also.

    Best regards,
    Kenneth

  • Hi,

    thanks for reply. I have implemented as it is shown on attached code. It compiles succesfull,  but handler is not called before/after events at all. Please any suggestion? 

    thanks,

    Pepam

    void ble_on_radio_active_evt(bool radio_active)
    {
         NRF_LOG_INFO("running");
    }
    
    static void radio_notification_init(void)
    {
        uint32_t err_code;
    
        err_code = ble_radio_notification_init(NRF_RADIO_PRIORITY_HIGH,
                                               NRF_RADIO_NOTIFICATION_DISTANCE_800US,
                                               ble_on_radio_active_evt);
    
        err_code = sd_radio_notification_cfg_set(NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE,
                                                 NRF_RADIO_NOTIFICATION_DISTANCE_800US);
        APP_ERROR_CHECK(err_code);
    }
    
    
    
    /**@brief Function for application main entry, does not return.
     */
    int main(void)
    {
    
    ret_code_t err_code;
        log_init();
    
        err_code = app_timer_init();
        twi_init();
        
        nrf_delay_ms(100);
        int rc = 0;
        rc = setup_hoge();
        nrf_delay_ms(100);
        
                //mpu_init();
        utils_setup();
        softdevice_setup();
        radio_notification_init();
        //ble_radio_notification_init(NRF_RADIO_PRIORITY_NORMAL, NRF_RADIO_NOTIFICATION_DISTANCE_5500US, handler(true));
    
            create_timers(); 
        //err_code = app_timer_start(data_send, APP_TIMER_TICKS(237), NULL);
        APP_ERROR_CHECK(err_code);
        simulator_setup();
        profile_setup();
    
        NRF_LOG_INFO("ANT+ Bicycle Speed and Cadence TX example started.");
    
        for (;;)
        {
            NRF_LOG_FLUSH();
            nrf_pwr_mgmt_run();
        }
    }

Reply
  • Hi,

    thanks for reply. I have implemented as it is shown on attached code. It compiles succesfull,  but handler is not called before/after events at all. Please any suggestion? 

    thanks,

    Pepam

    void ble_on_radio_active_evt(bool radio_active)
    {
         NRF_LOG_INFO("running");
    }
    
    static void radio_notification_init(void)
    {
        uint32_t err_code;
    
        err_code = ble_radio_notification_init(NRF_RADIO_PRIORITY_HIGH,
                                               NRF_RADIO_NOTIFICATION_DISTANCE_800US,
                                               ble_on_radio_active_evt);
    
        err_code = sd_radio_notification_cfg_set(NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE,
                                                 NRF_RADIO_NOTIFICATION_DISTANCE_800US);
        APP_ERROR_CHECK(err_code);
    }
    
    
    
    /**@brief Function for application main entry, does not return.
     */
    int main(void)
    {
    
    ret_code_t err_code;
        log_init();
    
        err_code = app_timer_init();
        twi_init();
        
        nrf_delay_ms(100);
        int rc = 0;
        rc = setup_hoge();
        nrf_delay_ms(100);
        
                //mpu_init();
        utils_setup();
        softdevice_setup();
        radio_notification_init();
        //ble_radio_notification_init(NRF_RADIO_PRIORITY_NORMAL, NRF_RADIO_NOTIFICATION_DISTANCE_5500US, handler(true));
    
            create_timers(); 
        //err_code = app_timer_start(data_send, APP_TIMER_TICKS(237), NULL);
        APP_ERROR_CHECK(err_code);
        simulator_setup();
        profile_setup();
    
        NRF_LOG_INFO("ANT+ Bicycle Speed and Cadence TX example started.");
    
        for (;;)
        {
            NRF_LOG_FLUSH();
            nrf_pwr_mgmt_run();
        }
    }

Children
Related