cancel
Showing results for 
Search instead for 
Did you mean: 

USB-HS (ULPI) on STM32H750

flyer31
Senior

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:

  • other processor (STM32H750 100pin instead of STM32H743 144 pins)
  • "Old-style" USB-B connector (instead of USB-B micro connector, which I used with the STM32H743 board)
  • No Ground layer on the top layer (containing the USB lines to the connector, only about 2cm long) - but in both cases I use 4 layer multilayer, and full ground plane directly under the USB lines,, the USB line width and distance the same ... as typically recommended... .

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... ..

14 REPLIES 14
DBywa
Associate

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;
 }

Mlee.1
Associate

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!

dominicc
Associate II

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?

BParh.1
Senior III

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

KHsu.3
Associate

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?

  1. Did you used USB3300 module to connect H743 board by dupont line?
  2. Do you used external crystal for STM32H743? (8M or 24MHz..)