2013-11-24 11:48 PM
I have a board that is connected to USB on a STM32F107 with the following pins
USB_OTG_VBUS : PA9USBDM : PA11USBDP : PA12I have a project that needs to use both Virtual Com Port and USB Mass Storage. It needs to re-enumerate the USB then do a software reset to enable the different USB class.I have tried various different things to get it to re-enumerate but so far have been unable to, the only way to re-enumerate is to unplug usb cable.These are some of the functions i have tried with no successUSB_OTG_DisableGlobalInt(&USB_OTG_dev);USB_OTG_WRITE_REG32(&USB_OTG_dev.regs.GREGS->GINTSTS, 0xBFFFFFFF);USB_OTG_CoreReset(&USB_OTG_dev);USBD_DeInit(&USB_OTG_dev);DCD_DevDisconnect(&USB_OTG_dev);NVIC_SystemReset();Would anyone have any ideas on how to get the USB to re-enumerate when it is configured with only these 3 pins for the STM32F107?2013-11-25 02:52 AM
You can make the USB interface on the STM32 simulate a disconnect. This is called a 'soft disconnect'
Try the following code (From STM32F4xx) // set bit SDIS in OTG_FS_DCTL reg USB_OTG_dev.regs.DREGS->DCTL |= 0x02;2013-11-25 05:49 AM
Hi, thanks for replying. I have put this code before the NVIC_SystemReset(); but it did not re-enumerate.
With the STM32F103 you just have to do a software reset with NVIC_SystemReset() and it will re-enumerate with no problems? I hope there is a way to do similar with the STM32F107...2013-11-25 07:59 AM
Hi
2 things - 1) put in a few ms delay before resetting the processor - remember that the USB host must poll the USB bus for changes! 2) check the data sheets for your device ! The code I posted was for a STm32F405 device not a STM32F1xx !2013-11-25 09:11 PM
Thanks, i will try the delay and also study the datasheet some more. I will report back with what i find.
2013-11-26 02:38 AM
Worked out what the issue was, there was a 1.5k external pull up resistor on the DP line which would not allow the usb soft disconnect to happen as the soft disconnect disables the internal pull up resistor on the DP line.