cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB5 USB CDC not working after STOP mode

Dracu
Associate II

Hello,

I am trying to use the USB virtual com port on an STM32WB5MMG. After trying to go into any of the stop modes, I cannot get the virtual com port to work again. (I am using the RTC alarm to wake up the MCU from stop mode and it wakes up fine)

I have tried these commands to get it to restart:

USBD_DeInit(&hUsbDeviceFS);
HAL_Delay(100);
MX_USB_Device_Init();
HAL_Delay(100);

I have also tried:

-Before the sleep:

USBD_Stop(&hUsbDeviceFS);

-After the sleep:

USBD_Start(&hUsbDeviceFS);

 

I tried the 2 above method with standby mode on a previous project on this MCU but I can't seem to get it going again.

 

Also, how I go into stop mode:

HAL_SuspendTick();
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
HAL_ResumeTick();

 

Does anyone have some suggestions on what it might be?

2 REPLIES 2
jbjoe30
Associate

Any luck resolving this?  I have a similar issue with mass storage (MSC).  After a hard boot, I can run the fatfs and USB initialization routines, and everything works as it should.  Then, after a deep sleep (STOP), the USB instantly jumps to ready, but internally, the state is at idle.  There are no idle handlers in the state machines, and it just hangs.  I've tried the deInit routines to no avail.

FBL
ST Employee

Hi @Dracu @jbjoe30 
You need to reconfigure system clock to re enable oscillators. Care must be taken to ensure that this process does not take more than 10 ms when the wakening event is an USB reset sequence.

 

void USB_Wakeup_IRQHandler(void) {

 if((&hpcd)->Init.low_power_enable)
  {
    /* Reset SLEEPDEEP bit of Cortex System Control Register */
    SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));  
    
    /* Configures system clock after wake-up from STOP: enable HSE, PLL and select 
    PLL as system clock source (HSE and PLL are disabled in STOP mode) */
    SystemClock_Config();
    
    /* ungate PHY clock */
     __HAL_PCD_UNGATE_PHYCLOCK((&hpcd)); 
  }
  /* Clear EXTI pending Bit*/
  __HAL_USB_OTG_FS_WAKEUP_EXTI_CLEAR_FLAG();
....

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.