Problem with re-initialization of USB CDC in device mode

I am working with lm3s5951 microcontroller which has usb host/device/otg facility in-built.

I could able to invoke USB OTG handler as per "SW-USBL-UG-7611.pdf" specification.

By using usb-id pin in floating to switch from/to host and device modes. In this process, Initialization and termination of Host mode usb drivers are working fine.

But when I invoke usb cdc termination API in device mode, and again initializing the same, my board is not getting configured in device mode properly. What could be the problem? I suspect on that, I am missing some other APIs in process of termination of USB cdc in device mode.

//// Open an instance of the mass storage class driver.//g_ulMSCInstance = USBHMSCDriveOpen(0, MSCCallback);

//// Initialize the power configuration. This sets the power enable signal// to be active high and does not enable the power fault.//USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);

I did not used USBStackModeSet() when I switch to device mode. But my application is working in device mode without 'StackModeSet' function also, when device mode Initialization function is called for the first time.

Note: I am using "USB0OTGModeIntHandler" for Host/Device Interrupts.

I am getting problem in re-initialization of device mode function call. When I am switch from Device mode to Host mode, I am Terminating device mode and Initializing Host mode. And I suspect on termination process of USB CDC in device mode, because when I switch back to Device mode from Host mode, I am terming Host mode and again Initializing Device mode, exactly here USB is not getting configured in device mode properly.

Anyway, first I will try using 'USBStackModeSet' function when switching to Device mode as per your suggestion.

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.