SDAA062 September 2025 TMS320F28P559SJ-Q1
The USB full speeds only allows maximum 64 bytes data transmission in one package. If there are multiple package transmissions required such as with HID touch screen data, TxPktRdy cannot be cleared by the hardware in time. This causes data loss during multiple package transmissions.
usbdenum.c:USBDEP0StateTx()[2580]:
g_psDCDInst[0].iEP0State = eUSBStateTx;
if(ui32NumBytes > EP0_MAX_PACKET_SIZE)
ui32NumBytes = EP0_MAX_PACKET_SIZE;
pui8Data = (uint8_t *)g_psDCDInst[0].pui8EP0Data;
g_psDCDInst[0].ui32EP0DataRemain -= ui32NumBytes;
g_psDCDInst[0].pui8EP0Data += ui32NumBytes;
USBEndpointDataPut(USB_BASE, USB_EP_0, pui8Data, ui32NumBytes);
usb.c:USBEndpointDataPut()[2806]:
if(HWREGB(ui32Base + USB_O_CSRL0 + ui32Endpoint) & ui8TxPktRdy)
return(-1);
Add enough delay cycle to make sure the TxPktRdy is cleared by the hardware correctly.
if(HWREGB(ui32Base + USB_O_CSRL0 + ui32Endpoint) & ui8TxPktRdy)
{
for (ui8Timeout = 0; ui8Timeout < 5; ui8Timeout++) {
USBDelay(1);
if(!(HWREGB(ui32Base + USB_O_CSRL0 + ui32Endpoint) & ui8TxPktRdy))
{
break;
}
}
if(HWREGB(ui32Base + USB_O_CSRL0 + ui32Endpoint) & ui8TxPktRdy)
{
//Force clean rdy bit
HWREGB(ui32Base + USB_O_CSRL0 + ui32Endpoint) &= ~ui8TxPktRdy;
}
}