Skip to main content
Associate II
June 28, 2025
Solved

STM32F411 switching between USB Host & Device and Middleware issues

  • June 28, 2025
  • 1 reply
  • 630 views

Hi all!

On an STM32 project I'm working on, I want my USB port (USB C in that case) to work either in Host Mode or in Device Mode, depending on a menu change from the user. For added context, this is for a MIDI project in which the MC will either use USB Host or USB Device as a means of communication.

It appears the mode is determined by the state of Pin PA13 (SYS_JTMS_SWDIO), but I would rather do everything in software, as the USB connection will be the same (the implementation will differ between the two).

Also, when I set the USB mode to OTH/Dual_Role_Device, all of the USB files are being deleted. Should I just save the files used in Host_Only and in Device_Only in another folder, or is there a cleaner way to have both implementations at the same time? If I need to code everything from scratch, I would love to have some pointers on where to begin.

Thanks in advance!

Best answer by Gyessine

Hello @Romder ,

Here is a link to an article that explains how to enable the NUCLEO H723 to switch between host and device modes. You can use it as a reference to assist with your F4 board project.

BR,

Gyessine

1 reply

GyessineBest answer
Technical Moderator
July 4, 2025

Hello @Romder ,

Here is a link to an article that explains how to enable the NUCLEO H723 to switch between host and device modes. You can use it as a reference to assist with your F4 board project.

BR,

Gyessine

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
RomderAuthor
Associate II
July 19, 2025

This is a great resource!

Thank you very much!