2023-11-15 12:15 AM
Trying to enable both USB and BLE at the same time I encountered difficulty
The USB failed to run.
I encountered the following ticket: usb-device-does-not-work-when-starting-ble-stack-on-stm32wb55 which had an example attached to it.
After trying several things from that example we saw that the only thing I needed was to lock HW semaphore number 5 (Which I found on other projects to be defined as CFG_HW_CLK48_CONFIG_SEMID).
Do note that the semaphore is never being released
I'm not entirely sure if what I did was correct.
My USB clock configuration is:
LL_HSEM_1StepLock(HSEM, 5);
// USB clock enable
memset(&PeriphClkInitStruct, 0, sizeof(PeriphClkInitStruct));
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
goto PeripheralClocksErr;
}
__HAL_RCC_USB_CLK_ENABLE();
Anyone from ST can verify/validate that this is the correct way to do it?
Thanks. Hagai
Solved! Go to Solution.
2023-11-30 05:34 AM
Hello,
The USB and RNG IPs share the same source clock (CLK48). The RNG IP is used by CPU2, the CPU2 can updates or switches off the clock only when the RNG IP (Sem0) is used. So, when CPU1 needs to use USB and BLE, it should take CFG_HW_CLK48_CONFIG_SEMID semaphore to avoid CPU2 to switch off CLK48 clock.
You can refer to AN5289 for more information around semaphore, see Sem5 description in part 4.3 Share peripherals.
Best Regards
2023-11-30 05:34 AM
Hello,
The USB and RNG IPs share the same source clock (CLK48). The RNG IP is used by CPU2, the CPU2 can updates or switches off the clock only when the RNG IP (Sem0) is used. So, when CPU1 needs to use USB and BLE, it should take CFG_HW_CLK48_CONFIG_SEMID semaphore to avoid CPU2 to switch off CLK48 clock.
You can refer to AN5289 for more information around semaphore, see Sem5 description in part 4.3 Share peripherals.
Best Regards