Close USB Connection Before Software Reset

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Close USB Connection Before Software Reset

729 Views
Mike_d
Contributor IV

I'm having issues with the host PC's virtual COM port getting hung up when the K20 performs a software reset.  So my question is:  What can I do to gracefully close the USB session prior to the software reset?

Labels (1)
2 Replies

496 Views
crezyoz
Contributor IV

Michael. If you are using COM ports, there really is no way to survive an unintentional disconnect. The port disappears from Windows Device list and from what I cold find, after a long time working with this problem, there is no way to solve the problem. As soon as the port is turned off or removed, the COM port code in your app will hang. It isn't even around for you to attempt to close it.

0 Kudos

496 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Michael,

The K20_120MHz product provides two USB modules, one is USB high speed module, the other one is USB Full/Low speed module.

For the USB high speed module, there with USB Command Register (USBHS_USBCMD) [RS] bit, clear this bit causes a detach event:

Device mode:

Setting this bit causes the controller to enable a pull-up on DP and initiate an attach event. This control bit is not directly connected to the pull-up enable, as the pull-up becomes disabled upon transitioning into high-speed mode. Software must use this bit to prevent an attach event before the USBHS controller has properly initialized. Clearing this bit causes a detach event.

For USB FS/LS module, USB module works as device mode with D+ pull up enabled. So, disable the D+ Pull Up at the USB transceiver as a detach event. Customer can clear USB OTG Control Register (USBx_CONTROL) [DPPULLUPNONOTG] bit.

Wish it helps.


Have a great day,
Ma Hui

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------