2019-03-05 08:55 AM
Hello All,
I updated to CubeMX 5 and use STM32F4 USB CDC.
After update my programm crashes directly after init.
This is because the USB driver calles directly into ErrorHandler when USB is not connected.
The ErrorHandler does a while(1) forever loop.
Why did STM changed that behaviour?
As in the ErrorHandler itself I have no possibility to test where it comes from and react according to the problem. The ErrorHandler is generic and global and should only be called on severe problems.
But a not connected USB interface is not "severe" but is a generic use-case.
What I currently do is to modify the ErrorHandler to return immediately.
I think this behaviour now is not good solution.
There should be a parameter in the call to ErrorHandler, so that ErrorHandler can react properly to the problem.
My 2ct.
Adib.
2019-03-05 12:39 PM
I observe the same problem too.
After some investigation , i found that in stm32f4xx_hal_pcd.c module line 1294 and 1298 , the used enumerations for hpcd->Init.speed are wrong. (at least).
Theese enumerations cause the problem in a next piece of code that checks the speed.
A temporary workaround is to replace the USB_OTG_SPEED_HIGH with PCD_SPEED_HIGH and to replace USB_OTG_SPEED_FULL with PCD_SPEED_FULL
2019-04-10 05:37 AM
I have faced the same problem with CubeMX 5 too.
The workaround is to change USB Core Speed define for USB_OTG_SPEED_FULL from 3U to 2U.
and USB_OTG_SPEED_LOW from 2U to 3U.
File: stm32f2xx_ll_usb.h
. . .
/** @defgroup USB_Core_Speed_ USB Core Speed
* @{
*/
#define USB_OTG_SPEED_HIGH 0U
#define USB_OTG_SPEED_HIGH_IN_FULL 1U
#define USB_OTG_SPEED_LOW 3U
#define USB_OTG_SPEED_FULL 2U
/**
* @}