AnsweredAssumed Answered

LPC4088 USB Device Write problem

Question asked by Priyank Bhatt on Jul 24, 2018
Latest reply on Aug 2, 2018 by jeremyzhou


I am working on a custom board with LPC4088 on it. I am using USB1 in device mode to communicate with the PC software in order to update firmware.

Initially I was using LPCOpen's usbd_lib_cdc  program to communicate to PC using terminal. So based on CDC code I have now changed it to vendor-specific USB code which is enumerated & recognized by the PC using our driver.

When I try to connect it to PC software it gets connected. The PC software sends the first char to start communication, which is read by the USB device successfully but when I try to write anything back, it fails to do that.

I observed that endpoint IN handler never gets called. And there is no IN packets when I call WriteEP().

Till now,

1. Tried to writing random packets without using PC software. Not working.

2. setup USB_Configure_Event which is called once on reset.

3. tried to write using TxData register as well.


This is my init code:

ErrorCode_t hmi_init(USBD_HANDLE_T hUsb, USB_CORE_DESCS_T *pDesc, USBD_API_INIT_PARAM_T *pUsbParam)
    USBD_API_INIT_PARAM_T hmi_param;
    ErrorCode_t ret = LPC_OK;
    uint32_t ep_indx;

    g_HMI.hUsb = hUsb;
    memset((void *) &hmi_param, 0, sizeof(USBD_API_INIT_PARAM_T));
    hmi_param.mem_base = pUsbParam->mem_base;
    hmi_param.mem_size = pUsbParam->mem_size;

    g_HMI.tx_buff = (uint8_t*)pUsbParam->mem_base;
    hmi_param.mem_base += HMI_RX_BUF_SZ;
    hmi_param.mem_size -= HMI_RX_BUF_SZ;
    g_HMI.rx_buff = (uint8_t*)pUsbParam->mem_base;
    hmi_param.mem_base += HMI_RX_BUF_SZ;
    hmi_param.mem_size -= HMI_RX_BUF_SZ;

    ep_indx = (((USB_HMI_IN_EP & 0x0F) << 1) + 1);
    ret = USBD_API->core->RegisterEpHandler(hUsb, ep_indx, HMI_bulk_in_handler, &g_HMI);
    if (ret == LPC_OK) {
        /* register endpoint interrupt handler */
        ep_indx = ((USB_HMI_OUT_EP & 0x0F) << 1);
        ret = USBD_API->core->RegisterEpHandler(hUsb, ep_indx, HMI_bulk_out_handler, &g_HMI);

    pUsbParam->mem_base = hmi_param.mem_base;
    pUsbParam->mem_size = hmi_param.mem_size;

    return ret;

I have seen many post/questions related to this & tried all of them but none worked.

I would appreciate if someone can help me.


Thank you.