2022-04-08 03:25 AM
Hi...Community
Hope you all are doing well
Recently, I'm dealing with the STM32WB custom hardware
In my application, i need the USB VCP logs during the BLE operation
And that's how I'm using USB CDC for the communication with the serial terminal
For me, I'm getting the debug logs at the serial terminal until the code reaches to CPU2 boot
When CPU2 comes in to the picture then, suddenly CDC logs stops due to wireless stack initialisation
After some googling, I got to know that the CPU2 uses the RNG, and that's how it's stopping the USB clock
Unfortunately Peripherals code settings not seems to be working for me as per the application note AN5289
I have attached code snippets for the Peripheral clock settings here
However, the same code generating the debug logs with the Nucleo board because of the lower version of the wireless stack on a top of it!
My custom board is running with the cube SDK version 1.11.1
void PeriphClock_Config(void) {
#if (CFG_USB_INTERFACE_ENABLE != 0)
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = { 0 };
RCC_CRSInitTypeDef RCC_CRSInitStruct = { 0 };
/**
* This prevents the CPU2 to disable the HSI48 oscillator when
* it does not use anymore the RNG IP
*/
LL_HSEM_1StepLock( HSEM, 5);
LL_RCC_HSI48_Enable();
while (!LL_RCC_HSI48_IsReady())
;
/* Select HSI48 as USB clock source */
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
/*Configure the clock recovery system (CRS)***********/
/* Enable CRS Clock */
__HAL_RCC_CRS_CLK_ENABLE();
/* Default Synchro Signal division factor (not divided) */
RCC_CRSInitStruct.Prescaler = RCC_CRS_SYNC_DIV1;
/* Set the SYNCSRC[1:0] bits according to CRS_Source value */
RCC_CRSInitStruct.Source = RCC_CRS_SYNC_SOURCE_USB;
/* HSI48 is synchronized with USB SOF at 1KHz rate */
RCC_CRSInitStruct.ReloadValue = RCC_CRS_RELOADVALUE_DEFAULT;
RCC_CRSInitStruct.ErrorLimitValue = RCC_CRS_ERRORLIMIT_DEFAULT;
RCC_CRSInitStruct.Polarity = RCC_CRS_SYNC_POLARITY_RISING;
/* Set the TRIM[5:0] to the default value*/
RCC_CRSInitStruct.HSI48CalibrationValue = RCC_CRS_HSI48CALIBRATION_DEFAULT;
/* Start automatic synchronization */
HAL_RCCEx_CRSConfig(&RCC_CRSInitStruct);
#endif
return;
}
All suggestions and recommendations welcome :)
Thanks
Mahendra
Solved! Go to Solution.
2022-04-13 08:37 AM
Hello,
Can you check HSI48ON bit in RCC_CRRCR register ?
You can also look BLE_TransparentModeVCP project for P-NUCLEO-WB55 USB Dongle which allows to use BLE and USB simultaneously. To use USB, it requires a semaphore which you need to set yourself. See : Building wireless applications with STM32WB Series microcontrollers - Application note Chapter Shared peripherals (Figure 9. Algorithm to use USB on CPU1).
Best Regards
2022-04-13 08:37 AM
Hello,
Can you check HSI48ON bit in RCC_CRRCR register ?
You can also look BLE_TransparentModeVCP project for P-NUCLEO-WB55 USB Dongle which allows to use BLE and USB simultaneously. To use USB, it requires a semaphore which you need to set yourself. See : Building wireless applications with STM32WB Series microcontrollers - Application note Chapter Shared peripherals (Figure 9. Algorithm to use USB on CPU1).
Best Regards
2022-04-27 06:46 AM
Hi.. @Remy ISSALYS
Thanks for your feedback
The issue has been resolved
Actually, I made some mistake at VCP drivers
Now it's working
Thanks