Skip to main content
Xxoyo.1
Associate III
May 7, 2021
Solved

MX_USB_DEVICE_Init() function call is not automatically add to main()

  • May 7, 2021
  • 2 replies
  • 1756 views

I have added the USB device via the CubeMX within STM32CubeIDE, however it have not automatically add the MX_USB_DEVICE_Init() function call at the main function. Do I have to enable something for this ? Or I'll have to manually add them myself?

0693W00000ANcLmQAL.png0693W00000ANcLrQAL.png0693W00000ANcM1QAL.png

This topic has been closed for replies.
Best answer by BParh.1

Is your application enabling FreeRTOS? If yes, check on the function task, it seems cubemx put it there instead of main body.

In fact from your snippet, it might me in TouchGFX task function where they put it as __weak. But since TouchGFX task override it, that is why it was not called and therefore you have to manually add it

2 replies

BParh.1
BParh.1Best answer
Senior III
May 7, 2021

Is your application enabling FreeRTOS? If yes, check on the function task, it seems cubemx put it there instead of main body.

In fact from your snippet, it might me in TouchGFX task function where they put it as __weak. But since TouchGFX task override it, that is why it was not called and therefore you have to manually add it

Xxoyo.1
Xxoyo.1Author
Associate III
May 7, 2021

Yes you're right, the MX_USB_DEVICE_Init call is placed inside the weak TouchGFX task. So it seems theres no other way but to manually add the init code ..