cancel
Showing results for 
Search instead for 
Did you mean: 

USB vcp reset problem

kqian
Associate II
Posted on May 15, 2014 at 16:58

Hi,

I am using USB HS port in the FS mode in my vcp project. When I used it to communicate to  PC, it works ok if I re-plug in the device to PC. The problem is if I just reset the MCU from IDE debug, the device cannot communicate any more unless I re-plug in the device again.

I check the register, the USBRST in OTG_HS_GINTSTS  is always 0. Anyone has the idea what's wrong happened in the software reset?

Thansk
7 REPLIES 7
chen
Associate II
Posted on May 15, 2014 at 17:23

Hi

''The problem is if I just reset the MCU from IDE debug, the device cannot communicate any more''

The PC does not know that the USB device has gone away and needs to re-enumerate the USB device.

When reseting the MCU - do a USB soft disconnect :

    // set bit SDIS in OTG_FS_DCTL reg

    USB_OTG_dev.regs.DREGS->DCTL |= 0x02;

kqian
Associate II
Posted on May 15, 2014 at 18:04

chen
Associate II
Posted on May 15, 2014 at 18:30

''

Where can I add it? Is there any function the program called before reset?

''

That is up to you to figure out.

If your program is resetting the MCU, you should know where the reset code is.

''The problem is if I just reset the MCU from IDE debug''

In this case - no there is no where for you to place the code. You have used the debugger to reboot the MCU.

kqian
Associate II
Posted on May 19, 2014 at 16:41

 I tried reboot from debugger, the COMPort is still visible from the computer device manager after I click Reset. after I re-run the program, the vcp is not working even the COMPort is till visible in the device manager. I have to replug in the USB connector to make it reset and works again. Looks something wrong.

chen
Associate II
Posted on May 19, 2014 at 17:17

'' I tried reboot from debugger, the COMPort is still visible from the computer device manager after I click Reset.''

OK, just tried it with my debugger.

Loading new binary into STM32 should make VCP diss-appear.

Pausing/stopping code execution using the debugger does not make the VCP diss-appear.

Resetting the code (ProgramCounter) using the debugger - VCP does not diss-appear

Restarting the code using the debugger - VCP does diss-appear and re-appear.

Something must be wrong with the USB init code.

''after I re-run the program, the vcp is not working even the COMPort is till visible in the device manager. I have to replug in the USB connector to make it reset and works again. Looks something wrong.''

If the COM port does not diss-appear - then the VCP port will no work.

It still thinks the old instance of the VCP is active. It is NOT.

kqian
Associate II
Posted on May 19, 2014 at 19:43

I tried domo code on the F4 discover board. When I click the Reset button from debugger, the COMPort disappeared from device manager.

I initialize the USB HS port as:

  RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOB , ENABLE); 

  

  /* Configure SOF VBUS ID DM DP Pins */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14 | GPIO_Pin_15;

  

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;

  GPIO_Init(GPIOB, &GPIO_InitStructure); 

  

  GPIO_PinAFConfig(GPIOB,GPIO_PinSource14,GPIO_AF_OTG2_FS) ;

  GPIO_PinAFConfig(GPIOB,GPIO_PinSource15,GPIO_AF_OTG2_FS) ;

  RCC_APB1PeriphClockCmd(RCC_AHB1Periph_OTG_HS_ULPI, ENABLE);

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_OTG_HS, ENABLE) ; I cannot find any problem here, just not very sure do I need special configure when I use HS Port as FS USB.

Thanks

chen
Associate II
Posted on May 20, 2014 at 10:05

''I initialize the USB HS port as:

....''

Where is this code?

It MUST be in void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev)

in usb_bsp.c

''I tried domo code on the F4 discover board. When I click the Reset button from debugger, the COMPort disappeared from device manager.''

Compare what the demo code is doing compared with what you are doing.