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: CC2540 BLE Disconnection problem

Part Number: CC2540

hi to all,

i am developing a device with TI CC2540 and i want to use CC2540 as central, i want to implement something like a bridge in this manner that cc2540 will at first subscribe to a notification charactristic and then it will forward every packet that it will receive from this notification charctristic to usb port, i implement a device that dose this job but cc2540 face to disconnection some times, i want know that it is possible writing to usb queue cause to disconnection??

my connection interval is 50ms.

outgoing usb endpoint is type of interrupt.

thanks

  • Hi Alireza,

    Please provide some more details about your application when you ask a hypothetical question like this. Yes, I suppose it is technically possible that the USB transfer could block the stack and cause a disconnect, but it's not very likely, especially if you use the UART-USB library that HostTestApp uses, but I can't say for sure without more information.

    Which example application are you basing this on?
    Which USB library? The one that emulates UART?
    How much data do you receive, how do you process it?
    What is the disconnect reason?
    How often does it happen?
    Is there some pattern to the disconnects?
    What else is your application doing?
    What is it connected to?

    Best regards,
    Aslak
  • Hi,

    Q: "Which example application are you basing this on?"
    R: actually i joined to project after project start and i do not know it is based on witch example but in my project i have void usbHidProcessEvents(void) function that polled by osal, in this function we check event mask to see any event was happend on endpoints or no, if any event happen then we will process it.

    Q: "How much data do you receive, how do you process it?"
    R: some time i send from ble peripheral(nrf5122) to central(CC2540) 20KB of data, sometime i send 500 Byte of data but disconnection sometime happen on 500 Byte and sometime on 20KB, i do not think that disconnection is related to size of data that are transferring. actually i want implement just a bridge of data between ble and usb, and i want just send data that recived from notification characteristic to usb, so when ble_process_gatt_msg called i switch on pMsg->method and if it was ATT_HANDLE_VALUE_NOTI i will copy pMsg->msg.handleValueNoti.pValue to an internal array then set an event to process it on my task event process routine, then when osal call my task process event routine i will try to forward received packet on usb, in below code you can see function that i use to write data on usb endpoint:

    uint8 usbfwFOBWrite(uint8 * data)
    {
    uint32 stopPoint = 100;
    uint8 oldEndpoint;
    // Save the old index setting, then select endpoint 0 and fetch the control register
    oldEndpoint = USBFW_GET_SELECTED_ENDPOINT();


    USBFW_SELECT_ENDPOINT(USB_HID_VFOB_EP);
    if(USBCSOL & USBCSOL_OUTPKT_RDY) /* buffer is full */
    {
    // Read FIFO
    if(usbReadBlocked==0)
    {
    usbfwReadFifo(&USBF2, USBCNTL, _data);
    USBCSOL &= ~USBCSOL_OUTPKT_RDY;
    }
    USBFW_SELECT_ENDPOINT(oldEndpoint);
    //return 0;
    }

    USBFW_SELECT_ENDPOINT(USB_HID_VFOB_EP_WRITE);

    // Send IN packets
    while((USBCSIL & USBCSIL_INPKT_RDY) && stopPoint>0)
    stopPoint--;
    if(stopPoint!=0) /* check timeout event */
    {
    usbfwWriteFifo(&USBF2, 64, data);
    USBCSIL = USBCSIL_INPKT_RDY;
    USBCSIL = USBCSIL_SEND_STALL;
    while ((USBCSIL & USBCSIL_SENT_STALL) && stopPoint>0)
    stopPoint--;
    }
    USBCSIL = 0;
    USBFW_SELECT_ENDPOINT(oldEndpoint);

    if(stopPoint==0)
    return 0; /* timeout event */
    else
    return 1; /* success send */
    }

    Q:"What is the disconnect reason"
    R: LL_STATUS_ERROR_CONN_TIMING_FAILURE is the disconnection reason that osal report.

    Q:"How often does it happen?"
    R: it has not any specific routine, it happen mostly when i transfer big data.

    Q:"What is it connected to?"
    R: i use cc2540 as central device and correspond peripheral that has nrf5122 ic on it.

    thanks for your attention.