cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with SHUTDOWN mode

DPesk.1
Associate II

Hello,

I have a board with stm32wb55. I can't enter to shutdown mode or can't to exit form shutdown.

I want to exit from this mode via wakeup pin 1 PA0. I use this code

if(   (LL_PWR_IsActiveFlag_C1SB() == 0)
     || (LL_PWR_IsActiveFlag_C2SB() == 0)
    )
	{
		/* Set the lowest low-power mode for CPU2: shutdown mode */
		LL_C2_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
	}
 
	HAL_PWREx_EnableGPIOPullUp(PWR_GPIO_A, PWR_GPIO_BIT_0);
 
	HAL_PWREx_EnablePullUpPullDownConfig();
	/* Disable used wakeup source: PWR_WAKEUP_PIN1 */
 
	HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
 
	HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN2);
 
	HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN3);
 
	HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN4);
 
	HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN5);
	/* Clear all related wakeup flags */
 
	__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF1);
 
	HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1_LOW);
	HAL_PWREx_DisableInternalWakeUpLine();
	/* enter shutdown */
 
	HAL_PWREx_EnterSHUTDOWNMode();

MCU enter to something mode (maybe it's shutdown) but I cant exit from it. Why? I don't understand. Before the entering I use this pin PA0 as input GPIO with pullup.

3 REPLIES 3
Mohamed Aymen HZAMI
ST Employee

Hello,

You can try this sequence :

if(   (LL_PWR_IsActiveFlag_C1SB() == 0)
     || (LL_PWR_IsActiveFlag_C2SB() == 0)
    )
  {
    /* Set the lowest low-power mode for CPU2: shutdown mode */
    LL_C2_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
  }
	
	HAL_PWREx_ClearWakeupFlag(PWR_FLAG_WUF1);
	HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1_HIGH);
  /* USER CODE END SysInit */
 
  /* Initialize all configured peripherals */
  
  /* USER CODE BEGIN 2 */
	HAL_SuspendTick();
	HAL_PWREx_EnterSHUTDOWNMode();

Best Regards,

Mohamed Aymen.

So, thanks. This code is working. But I haven't many problem with it :(

1) I have a button on this pin (PA0 - WakeUp1 pin). When button is pressed pin PA0 is connected to GND. But when button is not pressed pin PA0 in the Z-state. I haven't external pullup resistor on this pin and use internal pullup. This is my new code

if(	(LL_PWR_IsActiveFlag_C1SB() == 0)
		|| (LL_PWR_IsActiveFlag_C2SB() == 0))
	{
		/* Set the lowest low-power mode for CPU2: shutdown mode */
		LL_C2_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
	}
	
    HAL_PWREx_EnableGPIOPullUp(PWR_GPIO_A, PWR_GPIO_BIT_0);
    HAL_PWREx_EnablePullUpPullDownConfig();
 
    HAL_PWREx_ClearWakeupFlag(PWR_FLAG_WUF1);
    HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1_HIGH);
	
    HAL_SuspendTick();
    HAL_PWREx_EnterSHUTDOWNMode();

But when I enter to shutdown mode - CPU immediately exits it with PWR_FLAG_WUF1. Why? Can you help me with them)

2) Always after debug is starting (i use the Keil 5.29, compiler v5.06 build 750, st-link v2 mini) after function APPE_Init() hardware semaphore HSEM2 (CFG_HW_FLASH_SEMID) always bysu and Flag CFGBSY in FLASH_SR too.

0693W000000WLAaQAO.png

0693W000000WLAfQAO.png

I can erase or write to flash nothing!!! CPU2 don,t release this semaphore. At the same time I can't find my BLE device via my phone and at the same time i can't enter to shutdown mode. But if i press "reset CPU" in the Keil everything is getting good. Where is finding the problem? I use full_BLE_stack v1.5 and stm32WB55CGU

I also noticed that when I turn on the Debug at first registers PWR-C2CR1 = 0, PWR->C2CR2 = 0, PWR->EXTSCR = 0x00000F00. In this moment Hsem2 is busy CPU2 and I can't find my Bluetooth device.

0693W000000WPJHQA4.png

0693W000000WPJlQAO.png

But after reset PWR-C2CR1 = 4, PWR->C2CR2 = 0x00000200, PWR->EXTSCR = 0x00008F00

0693W000000WPKFQA4.png

I think the CPU2 is freezing. Why?