cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WBA65 example logic wrong in HAL_PCD_MspInit()?

JFisher-Legato
Associate II

Hello,

I'm chasing a problem where my project is having its configuration of SMPS mode switch back to LDO, and I was realizing that the settings are reset when USB is enabled. Digging into this, I came across this:

    /* Enable VDDUSB */
    if(__HAL_RCC_PWR_IS_CLK_ENABLED())
    {
      __HAL_RCC_PWR_CLK_ENABLE();
      HAL_PWREx_EnableVddUSB();
      HAL_PWREx_EnableUSBPWR();
      __HAL_RCC_PWR_CLK_DISABLE();
    }
    else
    {
      HAL_PWREx_EnableVddUSB();
    }

At a glance, the logic appears incorrect -- why would you enable PWR_CLK when you just checked and it was already enabled? I looked through the v1.7.0 SDK example projects, and saw that most other projects, the line is `if (__HAL_RCC_PWR_IS_CLK_ENABLED() != 1U)`. This only appears here:

./Projects/NUCLEO-WBA65RI/Applications/USBX/Ux_Device_CDC_ACM/Core/Src/stm32wbaxx_hal_msp.c:    if(__HAL_RCC_PWR_IS_CLK_ENABLED())
./Projects/NUCLEO-WBA65RI/Applications/USBX/Ux_Device_CDC_ACM/Core/Src/stm32wbaxx_hal_msp.c:    if(__HAL_RCC_PWR_IS_CLK_ENABLED())
./Projects/NUCLEO-WBA65RI/Applications/USBX/Ux_Host_HID/Core/Src/stm32wbaxx_hal_msp.c:    if(__HAL_RCC_PWR_IS_CLK_ENABLED())
./Projects/NUCLEO-WBA65RI/Applications/USBX/Ux_Host_HID/Core/Src/stm32wbaxx_hal_msp.c:    if(__HAL_RCC_PWR_IS_CLK_ENABLED())
./Projects/NUCLEO-WBA65RI/Applications/USBX/Ux_Device_HID_Standalone/Core/Src/stm32wbaxx_hal_msp.c:    if(__HAL_RCC_PWR_IS_CLK_ENABLED())
./Projects/NUCLEO-WBA65RI/Applications/USBX/Ux_Device_HID_Standalone/Core/Src/stm32wbaxx_hal_msp.c:    if(__HAL_RCC_PWR_IS_CLK_ENABLED())
./Projects/NUCLEO-WBA65RI/Applications/USBX/Ux_Host_HID_Standalone/Core/Src/stm32wbaxx_hal_msp.c:    if(__HAL_RCC_PWR_IS_CLK_ENABLED())
./Projects/NUCLEO-WBA65RI/Applications/USBX/Ux_Host_HID_Standalone/Core/Src/stm32wbaxx_hal_msp.c:    if(__HAL_RCC_PWR_IS_CLK_ENABLED())

Is this indeed a bug?

Thank you,
Jonathan

0 REPLIES 0