cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U575 USB battery charge detect fails on the second connection.

unicyclebloke
Associate III

My USB is a virtual COM port. I am trying to implement the BCD feature in order to detect what type of port is present when USB a cable is attached. We have charging capability and will use the type of the connected port to determine whether to enable charging, and also to restart the USB comms stack.

My code runs a non-blocking timer-driven state machine equivalent to HAL_PCDEx_BCD_VBUSDetect().

The first time I connect a cable, I can see the device appear in Windows Device Manager. I can open a Putty window and send/receive data. Success! When I disconnect the cable, Putty loses the connection as expected.

The second and subsequent times I connect the cable, I can again see the device appear in Windows Device Manager. I can again open a Putty window. But this time, no data is sent or received. It just seems to be dead.

What could explain this? It appears from other comments online that toggling between BCD and USB mode only works properly the first time. What is the fix for this? My code currently responds to a Disconnect by calling USB_Stop(), and to a Connect by Calling USB_Start(). Do I need to completely reset USB and start over from USB_Init()?

Thanks.

0 REPLIES 0