cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4Discovery and USB VCP

dvospierre
Associate II
Posted on January 17, 2015 at 07:18

I'm trying to get the USB device virtual comport going.  I created a project with STM32Cube choosing

Peripherals:

USB_OTG_FS Device_Only

MiddleWares:

USB_DEVICE Communication Device Class (Virtual Port Com)

Using Atollic TrueStudio I can build and burn.

The problem I'm having is when I hardware reset the board the call to MX_USB_DEVICE_Init hangs and the host does not detect the virtual com port.  However after I burn with st-link all is well and the port is detected.  It thus seems that a hardware reset, pressing the reset button or plugging the mini usb, causes the call to MX_USB_DEVICE_Init to freeze the cpu, but when burning with st-link which resets the cpu all is well.

Any ideas why this is happening?

Regards

Pierre
3 REPLIES 3
dvospierre
Associate II
Posted on January 17, 2015 at 13:41

I have traced to where the cpu stops, seems it is this line in stm32f4xx_ll_usb.c

USBx->GCCFG = USB_OTG_GCCFG_PWRDWN;

If I set an IO (blue LED) before the call and clear it again after, the LED stays on!

snip ...

  else /* FS interface (embedded Phy) */

  {

    

    /* Select FS Embedded PHY */

    USBx->GUSBCFG |= USB_OTG_GUSBCFG_PHYSEL;

    

    /* Reset after a PHY select and set Host mode */

    USB_CoreReset(USBx);

    

    /* Deactivate the power down*/

    HAL_GPIO_WritePin(GPIOD, (1 << 15), GPIO_PIN_SET);

    USBx->GCCFG = USB_OTG_GCCFG_PWRDWN;

HAL_GPIO_WritePin(GPIOD, (1 << 15), GPIO_PIN_RESET);

  }

jsvirzi
Associate II
Posted on January 19, 2015 at 22:33

This post will probably help

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F4%20Discovery%20Board%20and%20VCP%20USB%20drivers&currentviews=31]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F4%20Discovery%20Board%20and%20VCP%20USB%20drivers&currentviews=31
Posted on January 22, 2015 at 14:04

You can fix the wakeup ISR hang problem by inserting the following line of user code in the stm32f4xx_it.c file:

void OTG_FS_WKUP_IRQHandler(void)

{

  /* USER CODE BEGIN OTG_FS_WKUP_IRQn 0 */

 __HAL_GPIO_EXTI_CLEAR_IT(EXTI_PR_PR18);

  /* USER CODE END OTG_FS_WKUP_IRQn 0 */

  HAL_NVIC_ClearPendingIRQ(OTG_FS_WKUP_IRQn);

  HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS);

  /* USER CODE BEGIN OTG_FS_WKUP_IRQn 1 */

  /* USER CODE END OTG_FS_WKUP_IRQn 1 */

}

Given to me by ST support- they are aware of the problem and hopefully will fix on next release of Cube for F4.

IMHO it would be nice if they would post a dynamic list of known issues that will be fixed at a later date for all of us out here to access before they put up a new release. Lots of people chasing the same bugs could just check there first.