cancel
Showing results for 
Search instead for 
Did you mean: 

re-enumerate USB - STM32F107

justinwoolich
Associate III
Posted on November 25, 2013 at 08:48

I have a board that is connected to USB on a STM32F107 with the following pins

USB_OTG_VBUS : PA9

USBDM : PA11

USBDP : PA12

I 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 success

USB_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?
5 REPLIES 5
chen
Associate II
Posted on November 25, 2013 at 11:52

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;

justinwoolich
Associate III
Posted on November 25, 2013 at 14:49

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...

chen
Associate II
Posted on November 25, 2013 at 16:59

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 !

justinwoolich
Associate III
Posted on November 26, 2013 at 06:11

Thanks, i will try the delay and also study the datasheet some more. I will report back with what i find.

justinwoolich
Associate III
Posted on November 26, 2013 at 11:38

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.