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.

CC2540 USB dongle receive data unpunctually

Other Parts Discussed in Thread: CC2541

Hi,

I'm using the cc2541 Mini development Kit and trying to transmit the packet(10 bytes) every 10ms, i.e. our sample rate should be 1000 times/s. And I'm using the accelerometer sevice in sample project KeyFobDemo now. 

The problem is, every 5 transmissions (50 ms) the next packet will delay about 1s (which should be 10 ms). I changed the action of transmission to making P0_7 turn on and off to ensure that the transmission and the osal timer work fine. And the result was that the period of P0_7 signal is correct. Hence, I guess the problem lies in the receiver part. But I have no idea about why this will happen and how to solve it. Really urgent... Does anyone have any idea? 

Here is part of my code,

Thanks.

  • One possible way to do this is to use the HCI_EXT_ConnEventNoticeCmd function rather than OSAL timers, as a trigger to perform accelerometer reads. The OSAL clock is not synchronized with the stack timing, and OSAL events are not guaranteed to occur at the desired time (a higher priority event, such as a stack-related event, might cause delay). Using HCI_EXT_ConnEventNoticeCmd will let you perform an accelerometer read immediately after every connection event, and you could then send the data on the next event.

  • Hi Willis,

    Thanks for your reply. I've tried this method but it still doesn't work. I change to simpleBLEPeripheral sample project and this time not adding the adc but  the delay still occur. Here is my code,

    And one of my friend tell me to try another method instead of Accel_SetParameter, in this project the problem is solved.

    ///////////////////////////////////////////////
    if(events & SBP_NOTI_EVT){
    uint16 service = 0;
    static uint8 i = 0;

    attHandleValueNoti_t noti;
    gattAttribute_t *pAttr;

    osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_NOTI_EVT, 10 );

    CONST uint8 simpleProfilechar4UUID[ATT_BT_UUID_SIZE] =
    {
    LO_UINT16(SIMPLEPROFILE_CHAR4_UUID), HI_UINT16(SIMPLEPROFILE_CHAR4_UUID)
    };

    pAttr = GATT_FindHandleUUID( GATT_MIN_HANDLE, GATT_MAX_HANDLE, simpleProfilechar4UUID, ATT_BT_UUID_SIZE, &service );
    noti.handle= pAttr ->handle;

    noti.value[0] = i++;
    noti.len = 1;
    GATT_Notification(0, &noti, FALSE);

    return (events ^ SBP_NOTI_EVT);
    }
    ///////////////////////////////////////////////

    But once I add this,

    if((pAttr->pValue[0] == 1) && (pAttr->pValue[1] == 0)){

    noti.value[0] = i++;
    noti.len = 1;
    GATT_Notification(0, &noti, FALSE);

    Delay occur again!

    I wanna control my transmission flow with one button(maybe write 01:00 to one handle). Do you know what the problem is? Truly thank you!