cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 - USB HS Host - nothing happens

Microman
Associate III

Hi there,

I got some troubles getting the USB Host system working on the STM32H746ZI.

Worth mentioning is that this is no dev board here, just a plain H7 mcu on a DIY bread board. It is properly supplied with filtered 3.3 and 1.8V. Got UART, I2C, LCD peripherals working fine already. Only this USB host thing wont work at all.

My USB setup:

Pin75 D-

Pin76 D+

VBus pins are not used. USB devices are powered directly from linear 5V supply.

The code and project files are created with STcubeMX. FatFs and USB Host with MSC included.

What happens when I stick in an USB mem stick:

D+ goes high (up to about 0.6V) but no communication, no enumeration visible on the scope... debugging the USB_process loop there is never any change from IDLE state.

any idea what I could check?

1 ACCEPTED SOLUTION

Accepted Solutions
Ewelina Sz-P
Associate

We struggled with the same problem. Adding HAL_PWREx_EnableUSBVoltageDetector(); solved the problem.

For example :

void MX_USB_HOST_Init(void)

{

 /* USER CODE BEGIN USB_HOST_Init_PreTreatment */

 /* USER CODE END USB_HOST_Init_PreTreatment */

 /* Init host Library, add supported class and start the library. */

 USBH_Init(&hUsbHostFS, USBH_UserProcess, HOST_FS);

 USBH_RegisterClass(&hUsbHostFS, USBH_MSC_CLASS);

 USBH_Start(&hUsbHostFS);

 /* USER CODE BEGIN USB_HOST_Init_PostTreatment */

 HAL_PWREx_EnableUSBVoltageDetector();

 /* USER CODE END USB_HOST_Init_PostTreatment */

}

View solution in original post

10 REPLIES 10
FDixo
Associate III

We managed to get this working on a STM32H743. It would be a good idea to try out on a Nucleo or Discovery board - they usually only cost $20-$30. USB can be very complicated - but sounds like you have the CubeMX hardware configured correctly.

On the Nucleo boad, it is necessary to turn on the VUSB using a GPIO pin and a green light comes on. We purchased the Nucelo-H743 from Arrow electronics for $28.50 - turned up in 3 days.

Microman
Associate III

Thanks for the hint! I ordererd a Nucelo-H743 from Mouser now. We'll see how that one behaves. The good thing is that is exactly the same MCU like I am using on my bread board. But on the other side is, on the nucleo board they use the Full Speed USB peripheral only (as OTG) but I need a High Speed connection. Anyway, maybe I try playing around the VUSB pin, which I had currently not activated in cubeMX.

Microman
Associate III

I don't get it... received the NUCLEO-H743ZI board this week, connected a OTG-cable to the user USB port, took the original MXcube template for this board, created a project, added a line that switches on Pin PG6 (USB_PowerSwitchOn) so that VBus is applied and the VBus LED LD8 goes on, but there is still no USB activity at all... gState stays in mode HOST_IDLE. is_connected within the USB host USBH_HandleTypeDef struct also stays 0.

Any idea how to get this working? I couldn't find any demo projects for this Nucleo board that uses USB Host.

FDixo
Associate III
Hi, we use the STM32407VG sample example and just copied the relevant code. USB is quote complicated and there are quite a few steps to follow - for example after mounting the USB drive, it may take a few seconds before the USB can be accessed.
Microman
Associate III

OK thanks, I will have a look into the STM32F407 examples. I know about USB stack, enumeration process, dev classes and pipes etc. Few years ago I developed a USB device with the Atmel SAM chip, which was rather easy with the included samples and the ASF. The thing now with the STM32 is, that it does not even start the enumeration. Nothing happens if I connect some USB device to the pins, not even a single signal change comes out of the STM... Usual susbects are missing clock supply or peripheral power, but this all looks good... maybe the example code from 407 can help, we'll see.

Microman
Associate III

Sorry guys.... I have to come back on this. I still cannot get the USB HOST (FS1 on PA11 and 12) running on the 743ZI. On the 743XI it works tough.

What I did so far: I took the USB Host example from 743 EVAL board, disabled anything but USART and USB Host, switched USB clock source to RC48. VBUS detection is disabled, OTG ID all disabled. USB FS1 is configured as host only.

The code works seamlessly on the EVAL board (STM32H743XI). It immediatley enumerates any devices.

But nothing happens on the NUCLEO board (STM32H743ZI). The OTG_FS_IRQHandler is never called. (irqs on, others workign fine). USB Stick lights up, 5V is ready, pull-down resistor seems to be enabled.

I have of course enabled the USB drive power (MFX_GPIO7 on EVAL, PG6 on NUCLEO). Both USB Power LEDs are on (LD10).

No idea what's the matter here, as I think code should be compatible between ZI und XI of the H7 MCU. BTW to be sure the 48MHZ RC48 source is running, I routed the RC48 signal to PA8 (MCO1). It is there on both boards.

Any Ideas?

Ewelina Sz-P
Associate

We struggled with the same problem. Adding HAL_PWREx_EnableUSBVoltageDetector(); solved the problem.

For example :

void MX_USB_HOST_Init(void)

{

 /* USER CODE BEGIN USB_HOST_Init_PreTreatment */

 /* USER CODE END USB_HOST_Init_PreTreatment */

 /* Init host Library, add supported class and start the library. */

 USBH_Init(&hUsbHostFS, USBH_UserProcess, HOST_FS);

 USBH_RegisterClass(&hUsbHostFS, USBH_MSC_CLASS);

 USBH_Start(&hUsbHostFS);

 /* USER CODE BEGIN USB_HOST_Init_PostTreatment */

 HAL_PWREx_EnableUSBVoltageDetector();

 /* USER CODE END USB_HOST_Init_PostTreatment */

}

Looks much better now, many thanks Ewelina!

ST should mention this in their documentation.

Martin Franke
Associate III

Thank you Ewelina! This solved the problem to get the device working as well.