Hi,
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.
Priyank.
Hi Priyank Bhatt,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
The host is in charge of starting any kind of USB transactions, definitely, it includes IN transaction.
According to your statement, the LPC4088 doesn't receive IN token to call WriteEP(), so I'd highly recommend you to use the USB protocol tool to visualize the process of USB transferring, it can help us to analyze the issue.
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi jeremyzhou,
Thank you for your response.
I have seen the waveform using logic analyzer and host is continuously asking for IN packets but receives NAK.
I have checked ReEp register to see if endpoints are realized, it looks ok. Used event handlers to see for any unexpected event, but none occurred.
Also checked USB_Configure_Event as suggested in USB_Configure_Event called by USBD_API-&gt;hw-&gt;Init . It fires once after reset. The endpoint IN interrupt never fires.
Hi Priyank Bhatt,
In the usbd_lib_cdc demo, it uses the vcom_write and vcom_bread functions to send the data to PC or receive the data from PC. It's very clear and simple, so I'd like to know the code modification work you did and the testing process, it may give me more insight into this weird phenomenon.
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
hey jeremyzhou,
I have solved the problem. Changing endpoints worked. I have a doubt about fixed endpoints configuration in the user manual. What does it mean? Does that mean a particular endpoint is used with a specific configuration only?
Hi Priyank Bhatt,,
1) Does that mean a particular endpoint is used with a specific configuration only?
-- Yes, it does.
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Priyank Bhatt,
After testing and confirming with AE team, it should follow the reference manual.
Hope this is clear.
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Priyank Bhatt,
Definitely, it sounds contradictory and I'll reply you later after confirming with AE team.
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi jeremyzhou,
Thank you for your response.
I have seen the waveform using logic analyzer and host is continuously asking for IN packets but receives NAK.