This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Synchronize task to LE Connection Event using CC2640

Other Parts Discussed in Thread: CC2640, CC2540

I'm working on an application on a SmartRF06 Board using CC2640.


I'm currently sending sensor data via BLE and would like to synchronize my function for collecting sensor data right before the next LE Connection Event starts.

In CC2540 a synchronization should be possible using LL_TimeToNextRfEvent(), but this function doesn't seem to exist in CC2640.

  • Hi Henning,

    It is unfortunately not possible to know when the next connection event will happen from the application as the BLE scheduling mechanism has been changed and uses the TI RTOS Clock module to wake up again in time.
    The CC26XX TI RTOS Power driver has an API function called Power_getTicksUntilWakeup to receive the number of OS ticks until next interrupt but you will not know which wakeup this is as it might just as well be a periodic Clock object or a timeout from the UART driver.

    You can instead use the callback available from the stack that occurs right -after- the connection event has happened.
    This is documented under HCI_EXT_ConnEventNoticeCmd in SWRU393 (CC2640 BLE Software developers guide).

    Regards,
    Svend
  • Hello svendbt,
    your reply helped me to synchronize my application event with LE Connection Event, when no notification is registered.

    I notice that I must not synchronize my application event with LE Connection Event when a notification is registered, because my request to update data collected in the application event drive the BLE Stack to send these data within the next connection event. Technically I could set a timer to trigger my application event before the regular next LE Connection Event occur.

    I observed after each connection event triggered by a notification event an empty packet was sent in the next connection intervall. I have no Idea why this additional packet was sent. The MD Bit was not set within the first packed and I use slave latency.
    I expected the number of connection events defined within slave latency would be consecutively skipped after the notification was send before an empty packet will be send to preserve the connection (see Bluetooth Spec 4.1 Page 2538).

    My Configuration:
    GAPROLE_MIN_CONN_INTERVAL : 800
    GAPROLE_MIN_CONN_INTERVAL : 800
    GAPROLE_SLAVE_LATENCY : 4
    GAPROLE_TIMEOUT_MULTIPLIER : 1100

    The same behavior occured when using different configuration parameter. After a connection event occured because of a notification event an empty packet is sent within the next connection intervall. This behavior double the number of my connection events.
    Any Idea why this happens?
  • Hi,

    I'm not sure what you mean by notification event. But because of the protocol (slave is last to send), unless the slave wakes up on the next event to check SN/NESN from the master it can't be guaranteed that the data went through, and the master could potentially not get the data until next SL countdown.

    I can't say for 100% sure that this is the reason here, as I personally don't know that much about the CC2640 stack details, but it matches how I understood what you described.

    BR,
    Aslak
  • Hi Aslak,

    thanks for response.
    The SN/NESN check explain the observed behavior.