2010-05-05 09:25 AM
BUG? (USB_OTG_LIB)
2011-05-17 04:50 AM
Hi,
I had the same problem with the current library V3.2.1. I am using a CL device and the problem seems to be a bug in the library: Whenever you start a transfer and the last USB frame is pending, the TX Empty Fifo Interrupt is constantly asserted and the library keeps jumping into the interrupt routine until all data is read by the usb host, which usually blocks everything else. This is especially a problem if you send a packet of less then 64bytes (Max ep size in my case) and the host doesn't read it. There is nothing to reload into the fifo and the interrupt keeps triggering forever. I found the problem in the ot_fs_int.c file in function ''static uint32_t PCD_WriteEmptyTxFifo(uint32_t epnum)'' I modified this function, which solves the problem for the moment: static uint32_t PCD_WriteEmptyTxFifo(uint32_t epnum) { USB_OTG_DTXFSTS_TypeDef txstatus; USB_OTG_EP *ep; uint32_t len = 0; uint32_t dwords = 0; txstatus.d32 = 0; ep = PCD_GetInEP(epnum); len = ep->xfer_len - ep->xfer_count; if (len > ep->maxpacket) { len = ep->maxpacket; } //Begin Modified by Thomas Bretgeld if ((ep->xfer_len > 0) && (ep->xfer_count == ep->xfer_len)) { //Disable the Tx FIFO Empty Interrupt for this EP uint32_t fifoemptymsk = 0; fifoemptymsk = 1 << ep->num; USB_OTG_MODIFY_REG32(&USB_OTG_FS_regs.DEV->DIEPEMPMSK, fifoemptymsk, 0); } else { dwords = (len + 3) / 4; txstatus.d32 = USB_OTG_READ_REG32( &USB_OTG_FS_regs.DINEPS[epnum]->DTXFSTSx); while ((txstatus.b.txfspcavail > dwords) && (ep->xfer_count < ep->xfer_len) && (ep->xfer_len) != 0) { len = ep->xfer_len - ep->xfer_count; if (len > ep->maxpacket) { len = ep->maxpacket; } dwords = (len + 3) / 4; OTGD_FS_WritePacket(ep->xfer_buff, epnum, len); ep->xfer_count += len; ep->xfer_buff += len; txstatus.d32 = USB_OTG_READ_REG32(&USB_OTG_FS_regs.DINEPS[epnum]->DTXFSTSx); } } //End Modified by Thomas Bretgeld return 1; }2011-05-17 04:50 AM
Hi Thomas,
May I know if you are using this for Virtual COM port and trying to transfer stdio data over USB?
Thanks,
Sai