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

How can I send hid data with TIMER1_IRQHandler strict every 8ms?

I find it unstable to send hid data, even if I set timer 1 every 8ms to send hid data.

I can catch data bag from wireshark it seems that interval of two data even close to 1ms.

How can this happen?

but if I set timer every 15ms, it become more stable.

But I need send it every 8ms, can you help?

It is very stable in lenovo N700 mouse (nrf51822)

test soft is in attachments

Best regards

MouseMovementRecorder.zip

  • Hi,

    You should send mouse-movement each connection interval, not hard code it. I suspect that your link is not getting a optimal connection interval, which makes the mouse seem sloppy.

    Try:

    1. Check your connection interval, you should have < 15 ms.
    2. Send mouse data on the radio notification event (setup to happen x us before connection interval occurs) using the ble_radio_notification library

    Best regards Håkon

  • You mean this?

    #define MIN_CONN_INTERVAL               MSEC_TO_UNITS(7.5, UNIT_1_25_MS)            /**< Minimum connection interval (7.5 ms). */
    #define MAX_CONN_INTERVAL               MSEC_TO_UNITS(15, UNIT_1_25_MS)             /**< Maximum connection interval (15 ms). */
    
    

    And I can find "ble_radio_notification" be used in nrf51_sdk_v4_4_2_33551\nrf51822\Board\nrf6310\ble\ble_app_hids_mouse but not in nrf51_sdk_v5_1_0_36092

    where can I receive the radio notification event?

  • The library is located here: C:\Nordic Semiconductor\nRF51 SDK_v5.1.0.36092\Nordic\nrf51822\Source\ble

    Just add it to your project and initialize it, and the handler will then be executed x us before the connection interval occurs.

    -H

  • just like nrf51_sdk_v4_4_2_33551 ?

    init like this

    static void radio_notification_init(void)
    {
        uint32_t err_code;
    
        err_code = ble_radio_notification_init(NRF_APP_PRIORITY_HIGH,
                                               NRF_RADIO_NOTIFICATION_DISTANCE_4560US,
                                               ble_flash_on_radio_active_evt);
    
      	APP_ERROR_CHECK(err_code);
    }
    

    and send data in ble_flash_on_radio_active_evt() ?

    Does ble_flash_on_radio_active_evt() will be executed before the connection interval occurs

    what does

    void ble_flash_on_radio_active_evt(bool radio_active)
    {
        m_radio_active = radio_active;
    }
    

    do?

  • I try this code

    void mouse_send_on_radio_active_evt(bool radio_active)
    {
              m_radio_active = radio_active;
    	  mouse_sensor_send();
    }
    
    /**@brief Function for initializing the Radio Notification event.
     */
    static void radio_notification_init(void)
    {
        uint32_t err_code;
    
    
        err_code = ble_radio_notification_init(NRF_APP_PRIORITY_HIGH,
                                               NRF_RADIO_NOTIFICATION_DISTANCE_4560US,
                                               mouse_send_on_radio_active_evt);
    
      	APP_ERROR_CHECK(err_code);
    }
    

    and try to executed mouse_sensor_send(); before the connection interval occurs but it's not work as I expected.

Related