cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F723 USBPHYC LDO control documentation/HAL bug

Ben K
Senior III

So I'm looking at the reference manual of STM32F723 to find out how to control the USBPHYC peripheral. Actually there is no programmer's guide in there like for most peripherals, so I can only rely on the register map to find anything out about it. The LDO register has an LDO_DISABLE bit, that shall be set to 1 to disable the LDO.

Now let's check the HAL drivers:

stm32f7xx_ll_usb.c has USB_HS_PHYCInit() function to start the PHYC (but there's no function to stop it...). The first step of this function is:

  /* Enable LDO */
  USB_HS_PHYC->USB_HS_PHYC_LDO |= USB_HS_PHYC_LDO_ENABLE;

Well that's strange, I didn't find an LDO_ENABLE bit in the reference manual. But when I look at this definition, turns out:

/* Legacy */
[...]
#define USB_HS_PHYC_LDO_ENABLE                   USB_HS_PHYC_LDO_DISABLE

So this is confusing. To "Enable LDO", one must set the DISABLE bit? There must be an error in either the HAL drivers or in the reference manual (+ the CMSIS header of the devices). The question is, which one is the incorrect one? And when will it get fixed?

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

The reference manual is wrong. The bit enables the LDO.

https://community.st.com/s/question/0D53W00000BMA8HSAX/stm32f7xxh-strange-usbhsphycldoenable-definition

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

View solution in original post

3 REPLIES 3
Uwe Bonnes
Principal II

The joy of HAL: Learn again the redefined names that you read in the reference manual.

TDK
Guru

The reference manual is wrong. The bit enables the LDO.

https://community.st.com/s/question/0D53W00000BMA8HSAX/stm32f7xxh-strange-usbhsphycldoenable-definition

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

EDIT: look at the correct answer by @TDK.

> The LDO register has an LDO_DISABLE bit, that shall be set to 1 to disable the LDO.

Then obviously it's a DISABLE bit. It seems that initially it has been defined as ENABLE bit, corrected to DISABLE later, and added legacy define for compatibility. Therefore the reference manual and register definition file is now correct, but LL (not HAL) is still broken.

A better fix is to... Migrate to TinyUSB. 😉 Honestly, almost all HAL/Cube code is bloated and broken.