AnsweredAssumed Answered

STM32F05 USB No more interrupts

Question asked by Ar.Al on May 11, 2016
Latest reply on May 17, 2016 by Ar.Al
I found a very interesting situation, I can't explain (so no solution). We have a project and the USB connection is lost. Disconnecting and reconnecting the cable will not solve the situation and after the reconnection the device is not enumerated any more. The interrupt is not generated any more (this explain why the device is not enumerated).
Vsense is not implemented in hardware. So to detect a possible disconnection the SOF (USBx_DEVICE->DSTS  & USB_OTG_DSTS_FNSOF) is used. When the situation occured the SOF is changing even the cable is disconnecting. On the PA11 USB_OTG_FS_DM there's next effect as you can see in oscilloscope image
1.USB%20Line%20USB%20Disconnected%20After%20TO.NOK%20-%20Copy.png
Normally it shall be flat low :) and it's generated from the device side

When the situation is generated the descriptor is not fully transferred any more. AfterTO.png

Adding some code monitoring I found the last call as expected is 
else
    {
      /* Enable the Tx FIFO Empty Interrupt for this EP */
      if (ep->xfer_len > 0)
      {
        USBx_DEVICE->DIEPEMPMSK |= 1 << (ep->num);
   
in HAL_StatusTypeDef USB_EP0StartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep, uint8_t dma)

And after there's no interrupt anymore...
Any suggestions, solutions, deja-vu, comments, etc. are welcomed

The effect can be very easy reproduce by pressing F5 few times in USBLyzer

Attachments

Outcomes