cancel
Showing results for 
Search instead for 
Did you mean: 

StandBy mode wake up without WKUP pin after one cycle

JAgue.1
Associate II

Hi,

I'm testing the standby mode with a clear projet with the leds are gpio output and the user button, PA0 (WKUP1 pin) as gpio input.

I figured out how go in the standby mode one time.

But after one wake up my nucleo trigger the wake up by itself.

It seems that PWR_FLAG_WU and PWR_FLAG_SB are cleared.

I'm using a wire linked between PA0 to GND to simulate a raising edge when i unplug it, as mentioned before, it works for the first iteration.

There is my code:

  /* USER CODE BEGIN 2 */
 
  HAL_Delay(2000);
 
  if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET){
	  HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
	  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
  }
  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
 
  while (1)
  {
	  if(HAL_GPIO_ReadPin(USER_BUTTON_GPIO_Port, USER_BUTTON_Pin)==SET)
	  {
		  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
		  HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
		  HAL_PWR_EnterSTANDBYMode();
	  }
	  HAL_GPIO_TogglePin(LD1_GPIO_Port, LD1_Pin);
	  HAL_Delay(500);
}

To be more precise to how i'm processing:

  • Power Up the nucleo with PA0 and GND linked
  • LD1 the blinking after few seconds.
  • When i'm pressing the user button the nucleo goes in standby mode
  • After unlinking the PA0 and GND the nucleo wakes up
  • The LD2 switch on and LD1 blinking
  • Putting the wire between PA0 and GND again (i tried to put it when the button is pressed or before it didn't solved the problem).
  • Pressing the user button (STM goes in standby mode / led switching off)
  • After few seconds the LD2 switch on and the LD1 start blinking again
3 REPLIES 3
Sarra.S
ST Employee

Hello @JAgue.1​,

You need to make sure that the wake-up pin is disabled before toggling the LD2 LED. Otherwise, the wake-up flag might be set again and the MCU will wake up immediately which is happening in this case.

HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);

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.

Hello,

I tried to put the disabled like you did, then outside the if and then in the /*init*/ section but no one worked.

Did an action in other pin could trigger the wkup pin ?

Hello again @JAgue.1​,

Yes, it's possible for other pins to trigger the wake-up pin. but you're enabling the specific wake-up pin using HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1),

So the wake-up PIN1 is disabled before toggling the LD1 LED and waiting for the button press. It's only enabled and cleared just before entering standby mode.

You can test this and monitor the PA0 pin using an oscilloscope or logic analyzer to see if there are any unexpected signals or noise. This way, we are sure that the wake-up pin is not triggered inadvertently by other signals.

And maybe try using different pin? or use an external interrupt controller to debounce the signal

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.