AnsweredAssumed Answered

USB crash when using endpoint 0x84 but works on 0x81 (solved)

Question asked by zhao.frank on Nov 19, 2013
I am using a STM32F205RG, the USB HS interface as a USB device, it's HID, but it must use 0x84 for interrupt-in endpoint, not 0x81.
I am using the ST USB library.
If I attempt to use 0x84, a crash happens inside usb_core.c, function USB_OTG_EPStartXfer
USB_OTG_WRITE_REG32(&pcore->regs.INEP_REGS[ep->num]->DIEPCTL, depctl.d32);
using runtime debugging I have verified that ep->num does equal to 4, the entire pointer points to 0x40040980, which is correct for OTG_HS_DIEPCTL4
but as soon as this statement executes, my code jumps to some odd location
I am initializing the EP correctly as far as I can tell, the endpoint numbers are consistent between the EP opening, EP usage, and device descriptor. USB_OTG_MAX_TX_FIFOS is also set to 15. The number of endpoints available should be 6 according to USB_OTG_SelectCore, 4 is definitely less than 6.
If I use 0x81, the entire code works as expected, no crashes.
As it turns out, the problem may have been the FIFO allocation. The endpoint number translates into a FIFO number, which is 4, and FIFO 4 does not even exist. (FIFO 2 and 3 have 0 bytes allocated, FIFO 0 has 64 bytes for EP0 and FIFO 1 has 128 allocated)
The solution was to edit the library code so that FIFO 1 is used even if the endpoint is 4. I hope future versions of the library will address this issue.