2019-08-12 01:56 AM
Hi,
is somebody operating the STM32H750 successfully with USB-HS (ULPI Interface)?
I succeeded in running the USB device CDC example of the STM32H743 evaluation board on my STM32H743 test board (144 pin LQFP) - but when I try the same with a test board using the STM32H750 (100 pin LQFP), it does not work. I use the USB3300 chip for the interface.
I changed 3 things on this board:
I now will try to use the STM32H743 LQFP 100pin version on the 750 test board ... I will know more tomorrow I hope... .
(but if I look at all the datasheets, such a USB ULPI software running on STM32H743, it should run without changes also on the STM32H750 ... as I see it, e, g. all the peripheral memory addresses are really identical... . I have some other STM32H750 application, this is running with processor setting STM32H743 without any problems... ..
2019-08-30 09:11 AM
Patch in STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c
STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c | 64 +++++++++++++++++++++--------
1 file changed, 47 insertions(+), 17 deletions(-)
diff --git a/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c b/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c
index 74bbba8..fc0a713 100644
--- a/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c
+++ b/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c
@@ -49,6 +49,27 @@
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
+
+/** @defgroup USB_OTG_GRSTCTL_AHBIDL_TIMEOUT_MS AHB master idle timeout
+ * @{
+ */
+#define USB_OTG_GRSTCTL_AHBIDL_TIMEOUT_MS ((uint32_t)50U)
+
+/** @defgroup USB_OTG_GRSTCTL_CSRST_TIMEOUT_MS Core soft reset timeout
+ * @{
+ */
+#define USB_OTG_GRSTCTL_CSRST_TIMEOUT_MS ((uint32_t)10U)
+
+/** @defgroup USB_OTG_GRSTCTL_TXFFLSH_TIMEOUT_MS Tx FIFO flush timeout
+ * @{
+ */
+#define USB_OTG_GRSTCTL_TXFFLSH_TIMEOUT_MS ((uint32_t)5U)
+
+/** @defgroup USB_OTG_GRSTCTL_RXFFLSH_TIMEOUT_MS Rx FIFO flush timeout
+ * @{
+ */
+#define USB_OTG_GRSTCTL_RXFFLSH_TIMEOUT_MS ((uint32_t)5U)
+
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
@@ -441,19 +462,22 @@ HAL_StatusTypeDef USB_DevInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cf
*/
HAL_StatusTypeDef USB_FlushTxFifo(USB_OTG_GlobalTypeDef *USBx, uint32_t num)
{
- uint32_t count = 0U;
+ uint32_t tickstart;
USBx->GRSTCTL = (USB_OTG_GRSTCTL_TXFFLSH | (num << 6));
- do
+ /* Get tick */
+ tickstart = HAL_GetTick();
+
+ /* Wait for AHB master IDLE state. */
+ while((USBx->GRSTCTL & USB_OTG_GRSTCTL_TXFFLSH) == USB_OTG_GRSTCTL_TXFFLSH)
{
- if (++count > 200000U)
+ if((HAL_GetTick() - tickstart) > USB_OTG_GRSTCTL_TXFFLSH_TIMEOUT_MS)
{
return HAL_TIMEOUT;
}
}
- while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_TXFFLSH) == USB_OTG_GRSTCTL_TXFFLSH);
-
+
return HAL_OK;
}
@@ -464,18 +488,21 @@ HAL_StatusTypeDef USB_FlushTxFifo(USB_OTG_GlobalTypeDef *USBx, uint32_t num)
*/
HAL_StatusTypeDef USB_FlushRxFifo(USB_OTG_GlobalTypeDef *USBx)
{
- uint32_t count = 0;
+ uint32_t tickstart;
USBx->GRSTCTL = USB_OTG_GRSTCTL_RXFFLSH;
- do
+ /* Get tick */
+ tickstart = HAL_GetTick();
+
+ /* Wait for AHB master IDLE state. */
+ while((USBx->GRSTCTL & USB_OTG_GRSTCTL_RXFFLSH) == USB_OTG_GRSTCTL_RXFFLSH)
{
- if (++count > 200000U)
+ if((HAL_GetTick() - tickstart) > USB_OTG_GRSTCTL_RXFFLSH_TIMEOUT_MS)
{
return HAL_TIMEOUT;
}
}
- while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_RXFFLSH) == USB_OTG_GRSTCTL_RXFFLSH);
return HAL_OK;
}
@@ -1289,30 +1316,33 @@ HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t dma, uin
*/
static HAL_StatusTypeDef USB_CoreReset(USB_OTG_GlobalTypeDef *USBx)
{
- uint32_t count = 0U;
+ uint32_t tickstart;
+
+ /* Get tick */
+ tickstart = HAL_GetTick();
/* Wait for AHB master IDLE state. */
- do
+ while((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0U)
{
- if (++count > 200000U)
+ if((HAL_GetTick() - tickstart) > USB_OTG_GRSTCTL_AHBIDL_TIMEOUT_MS)
{
return HAL_TIMEOUT;
}
}
- while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0U);
/* Core Soft Reset */
- count = 0U;
USBx->GRSTCTL |= USB_OTG_GRSTCTL_CSRST;
- do
+ /* Get tick */
+ tickstart = HAL_GetTick();
+
+ while((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST)
{
- if (++count > 200000U)
+ if((HAL_GetTick() - tickstart) > USB_OTG_GRSTCTL_CSRST_TIMEOUT_MS)
{
return HAL_TIMEOUT;
}
}
- while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST);
return HAL_OK;
}
2021-01-06 03:17 AM
HI, flyer31
I'am trying do some work on STM32H743VIT6 (100 pin) and USB3300, I can not able to get through on OTG-HS.
will you please share some bsp code (clock setting, usb conf...) with me ?
thanks!
2021-05-30 09:45 AM
Thanks for posting the patch. I ran into this, it was occuring much more frequently in RELEASE builds (code is more optimized, runs faster) on an H730 running at 520Mhz. It took ages to track down the problem and sure enough I had an issue with the `USB_OTG_GRSTCTL_CSRST` timeout too.
ST still haven't fixed this in the latest (v1.9.0) CubeH7 HAL drivers and it's been 2 years since you posted the patch.
Did you open a support case with them regarding this?
2021-05-30 10:28 PM
I encountered the same issue, I resolved by decreasing my HCLK, I did not why so at that time, but then this forum seem to explain it. I hope ST fix this
2023-02-15 06:06 AM
My MCU is STM32H743IIT6, I used dupont line to connect to USB3300 module. Right now I met "Device not recognized" on PC.
I have 2 questions, could you help me to check it?