2015-01-16 10:18 PM
I'm trying to get the USB device virtual comport going. I created a project with STM32Cube choosing
Peripherals:USB_OTG_FS Device_OnlyMiddleWares: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?RegardsPierre2015-01-17 04:41 AM
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);}
2015-01-19 01:33 PM
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¤tviews=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¤tviews=312015-01-22 05:04 AM
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.