cancel
Showing results for 
Search instead for 
Did you mean: 

Nucleo-H563ZI as USB host?

algernon77
Associate II

Hello,

I would like to know if Nucleo-H563ZI board could be used as a USB host, using the user USB (CN13). I'm asking because I'm a bit confused, honestly - I've only found examples where it's being used as a device and the board manual seems to mention only as device and sink only for the CN13 connector. OTOH, in CubeIDE, after starting a new project based on this board, the USB and USBX can be configured as host, without any restriction. And, if it's possible, should UCPD1 and USBPD be enabled along with USB and USBX, or it's enough to call HAL_PWREx_EnableVddUSB at the end of HAL_HCD_MspInit?

 

Basically, what I want to implement is reading VID, PID and SN from a USB storage device plugged in CN13 and printing them over USART3.

Thanks!

10 REPLIES 10
AScha.3
Chief II

Hi,

USB host possible, yes ; i have tried as audio host ...working.

I just set jumper JP2 : stlink+chgr+usb_user , so with debug USB all is working.

look in circuit:

AScha3_0-1709398840633.png

 

If you feel a post has answered your question, please click "Accept as Solution".

Thanks for answering,

 

So, to make sure I understand correctly - I already have JP2 in the STLK position, do I have to add 2 more jumpers, in the CHGR and USB_USER positions? I was under the impression that only one jumper is allowed at one moment, since JP2 is the power source selector for the board?

With the jumpers JP2 you decide, what to connect to 5V .

I needed 5V with max. power at the USB_USER for connecting sound card; if you want same, need 3 jumpers.

if not sure, just look at the circuit, there you see, what you connect.

https://www.st.com/resource/en/schematic_pack/mb1404-h563zi-c01-schematic.pdf

 

If you feel a post has answered your question, please click "Accept as Solution".

Thanks,

Just tried a test project, the usb stick receives power, however, the ux_host_event_callback does not get called. USB, USBX and THREADX all initializes correctly, ux_host_event_callback is registered ok. I'm out of ideas 🙂

I just can say, one of the big problems to get it working - was : it was not enabled !

Depends on version of the HAL lib, maybe error is corrected already, or : look, debug etc. 

- or just try:

in file Core/Src/stm32h5xx_hal_msp.c  add in HAL_HCD_MspInit() (enable the USB) :

 

  /* USER CODE BEGIN USB_DRD_FS_MspInit 1 */
    HAL_PWREx_EnableVddUSB();
  /* USER CODE END USB_DRD_FS_MspInit 1 */

 

 

If you feel a post has answered your question, please click "Accept as Solution".

I've already inserted  HAL_PWREx_EnableVddUSB() at the end of HAL_HCD_MspInit(). I also tried reading DP and DM pins before and after USB device insertion, they're both low upon start and high after device insertion. Upon removal,  DP goes down in a few moments and DM also goes down after 30 seconds or so.

 

So there's definitely something going on, but not the right thing 🙂

 

What i would do: try to see the debug messages... 

You have SWD running ? then can see , what the USB telling , like here on usb stick inserted:

(here in cubeProgrammer , but same in IDE -> swv data console )

AScha3_0-1709457054990.png

--- or you use the vcp serial, on H563-nucleo board already connected also.

 

+

>I also tried reading DP and DM pins before and after USB device insertion

How you did this ? 

Look at dp+ line with a scope !  Insert usb you see dp+ going hi - enumeration begins... test it !

If you feel a post has answered your question, please click "Accept as Solution".

Hi,

I've read DP and DM pins with HAL_GPIO_ReadPin, in a interrupt handler assigned to the user button. They're low before insertion and high after.

 

I have the CubeProgrammer and I tried to view trace debug through SWV, but the problem is that I cannot seem to enable trace debug in ThreadX/UsbX (when I define TX_ENABLE_EVENT_TRACE in tv_user.h, the compiler gives about 200 errors 🙂 ). How did you enable trace debug with UsbX in your project?

 

 

UPDATE:

I've enabled event tracing with ThreadX - it was necessary to also enable TraceX support in the IOC. Will dig deeper and see if I'm able to make something of it.