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

  • radio_active states if the connection event has just happened, or is just about to happen. If this is active, then the handler is executed right before a connection interval is to happen.

    you should only push data if radio_active == true (or false). If you try to push data on both events, you will end up sending twice as many packets.

    -H

  • I have search the "S110_SoftDevice_Specification_v1.2" and find what you said "Radio Notification" on page 14

    And it said that in Table 14, when t(ndist) =5500, and t(interval) = 7.5 it will send just 1 packet between a interval

    so I set CONN_INTERVAL like this:

    
    #define MIN_CONN_INTERVAL                MSEC_TO_UNITS(7.5, UNIT_1_25_MS)            
    #define MAX_CONN_INTERVAL               MSEC_TO_UNITS(7.5, UNIT_1_25_MS)
    

    But I don't know where to set t(ndist)

    In "static void gap_params_init(void)" I cant find any params of t(ndist)

        gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
        gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
        gap_conn_params.slave_latency     = SLAVE_LATENCY;
        gap_conn_params.conn_sup_timeout  = CONN_SUP_TIMEOUT;
    

    And what's "SLAVE_LATENCY" mean? Where and how can I use it?

    I just want send 1 packet in one interval(7.5ms) ,

    Does "Radio Notification " will be ACTIVE every 7.5ms when I set CONN_INTERVAL like above?

    This is the most difficult problem we meet.

    Best regards.

  • I try code above ,if I set MIN_CONN_INTERVAL MAX_CONN_INTERVAL the same val I will get error 13 (Operation timed out) when run

    static void bond_manager_error_handler(uint32_t nrf_error)
    {
        APP_ERROR_HANDLER(nrf_error);
    }
    

    #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(7.5, UNIT_1_25_MS) /< Maximum connection interval (7.5 ms). */

    So how can I set interval to7.5ms or 8ms and send just one package in a interval ?

  • There's a bit of chaos in your development process now, as I see it. You should revert a couple of steps back, and start implementing the radio notification again, and set it up properly.

    1. The connection interval is set by the master. The slave can reject a connection if the master cannot provide the requested limits and disconnect the link, which is most likely what you're seeing. Try upping your max_conn_interval.

    2. You should setup radio_notification with the desired distance before the event handler is fired (set up in your ble_radio_notification_init function. Since the handler will be called twice per interval (one before, and one after a interval has happened), you should only send mouse data every other time the radio_notification handler is called.

    3. Slave latency is a part of the bluetooth specification. This allows the slave to skip connection intervals if no new data is to be sent. You can read more about this feature in the Core-spec.

    Best regards Håkon

Related