Skip to main content
DPesk.1
Associate II
April 20, 2020
Question

Problem with SHUTDOWN mode

  • April 20, 2020
  • 1 reply
  • 1531 views

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.

This topic has been closed for replies.

1 reply

Mohamed Aymen HZAMI
ST Employee
April 22, 2020

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.

DPesk.1
DPesk.1Author
Associate II
April 23, 2020

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