AnsweredAssumed Answered

Unplug USB from stm32f205 during data exchange

Question asked by Popov.Slava on Jan 18, 2017
Latest reply on Mar 10, 2017 by ssingh

Hello there.

I have problem with USB Device CDC based MX Cube for stm32f205.
When custom program exchange data with device I unplug USB. Then after some time I connect cable again.
I can see that device send data from previous transfer (which was not sent in last transaction because I unplug USB) instead I send using CDC_Transmit_FS.
Next behaviour looks like as FIFO. For example:
1) I send 0x00 0x01 0x02 but receive old data (which device send at moment I unplug USB)
2) I send 0x03 0x04 0x05 but receive 0x00 0x01 0x02
3) I send 0x06 0x07 0x08 but receive 0x03 0x04 0x05

Before call CDC_Transmit_FS I write in console what data I send. So I sure that correct data should be sent.

If I manually call USBD_DeInit and MX_USB_DEVICE_Init after then data start send in valid sequence.

What is the problem?

Also I`ll try to handle this case in HAL_PCD_DisconnectCallback but when I unplug USB it is no called. Instead this calls HAL_PCD_SuspendCallback.

What I need to do for fix it.