Skip to main content
Guide

How to implement USBX in standalone mode

  • August 5, 2025
  • 1 reply
  • 10 views

Eliza

Summary

The following article is a tutorial on how to implement the USB device, HID mouse class, using the Azure RTOS USBX package in standalone mode (without the RTOS).

1. Introduction

Hello developer and welcome to this article! For this tutorial, we use the NUCLEO-H723ZG board, which has a USB OTG_FS connector interface to open an HID class to work as a mouse. This board has an STM32H723ZGT6 microcontroller, and the steps shown here can be easily adapted to any other STM32. The STM32CubeIDE 1.13.1, the STM32CubeH7 1.11.1, and the X-CUBE-AZRTOS-H7 3.1.0 releases were used to build this tutorial. Standalone support is not present for all STM32 series yet. Refer to the proper release note of each series for more details on the current support.

BMontanari_0-1701201503044.jpeg

2 Development

2.1 Project creation

Let us start creating a project for the STM32H723ZGT6 in the STM32CubeIDE and enabling the following pins to get access to the LEDs available on the board.

PB0 as GPIO Output Push Pull, labeled as LD1_GREEN.

PE1 as GPIO Output Push Pull, labeled as LD2_YELLOW.

PB14 as GPIO Output Push Pull, labeled as LD3_RED.

 

BMontanari_1-1701201503083.png

Then configure the PC13 pin as GPIO_Input with the “USER_BUTTON” as label to allow us to read the state of the User Button available on the Nucleo board.

Down to the USB_OTG_HS menu, under the "Connectivity" tab. Once you have selected the USB peripheral tab, select the "Device_Only" option in the "Internal FS Phy." Afterwards, enable the "USB On the Go" HS global interrupt under the NVIC Settings tab. Doing that, the Clock Settings tab will signalize an error, but do not worry, we will correct it in the next step.

BMontanari_2-1701201503094.png

Go to the Clock Configuration tab. We suggest increasing the frequency of HCLK to achieve the best application performance. See the clock example settings used for this application.

BMontanari_3-1701201503100.png

 

Most importantly, change the USB Clock Mux source to the HSI48.

BMontanari_4-1701201503101.png

 

2.2 Configure the CUBE-AZRTOS-H7 package and USBX

After doing that, go back to the "Pinout & Configuration tab", navigate until the X-CUBE-AZRTOS-H7 under the "Middleware and Software Packs" menu. By clicking in this item, the "Software Packs Component Selector" is opened. If you do not have the USBX package, click the install button to download it.

Once the package is installed, enable the following required components:

  • USB USBX -> USBX -> CoreSystem
  • USB USBX -> USBX -> UX Device CoreStack
  • USB USBX -> USBX -> UX Device Controller
  • USB USBX -> USBX -> UX Device Class HID Core
  • USB USBX -> USBX -> UX Device Class HID Mouse

 BMontanari_5-1701201503105.png

Note: a warning message might appear, but it can be ignored. 

You can select different classes depending on your application. Make sure to have the CoreSystem, CoreStack, and Controller enabled. These components are required for the application. After selecting the packages, press OK.

Now, back to the X-CUBE-AZRTOS-H7 under the "Middleware and Software Packs" and enable USB USBX components:

BMontanari_6-1701201503110.png

Once the USB USBX package is enabled, a configuration menu is shown. In the AzureRTOS application, we need to increase the UXDevice memory buffer size and the USBX Device System Stack Size. For the HID class, 5KB is sufficient for our application. Enabling the information menu, you are able to see the suggested amount of memory needed for each class when selecting the USBX Device System Stack Size:

BMontanari_7-1701201503114.png

It is necessary to set a timebase for our application. Since we are not using RTOS, we can use the default SysTick to be our timebase. So, go to System Core->SYS and select the SysTick as the timebase source:

BMontanari_8-1701201503116.png

2.3 Code generation

Now, go to the "Project Manager" tab and then the "Code Generator" section. Enable the “Generate peripheral initialization as pair of ‘.c/.h’ files per peripheral”. This facilitates the access to the peripheral resources in the code.

 

BMontanari_9-1701201503144.png

The final last step is to disable the USB_OTG_HS peripheral initialization code in the Advanced Settings also in the Project Manager.

 

BMontanari_10-1701201503165.png

Now, that all the settings are configured you can generate the code. For that you can use the alt + K shortcut or press the generate button.

 

BMontanari_11-1701201503168.png

 

 

1 reply

  • Community Manager
  • August 21, 2025

Testing replies on knowledge base articles