cancel
Showing results for 
Search instead for 
Did you mean: 

Wake up Pin from standby mode

Ehill.16
Senior

I am using wake up PIN1 (PA0) to wake the STM32F746 from standby mode. I have PA0 connected to a push button with a pull down resistor. When first powered up the MCU goes into standby mode and stays in it until I press the button connected to PA0. The MCU wakes up for about 10 seconds and then goes into standby mode again. But then it wakes up with out me pressing the button and continues this cycle. The PA0 pin is configured as a wakeup pin.

Here is the code to detect if the MCU is woken from standby mode:

	// check standby mode flag
	// reset if it is still set
	if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
	{
		__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);				// clear the SB flag
		HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);		// disable wakeup pin1		
	}

Here is the code for putting MCU into standby mode:

void enter_standby(void){
	// clear the wake up flag
	__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
 
	// display Stdby Mode on the OLED
	ssd1306_Fill(Black);			// clear the SSD1306 OLED display
	ssd1306_SetCursor(0, 0);
	ssd1306_WriteString("Stdby Mode ", Font_11x18, White);
	ssd1306_UpdateScreen();
 
	/* Enable WKUP pin */
	HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
	/* Enter Standby Mode , wake up with a rising edge on PA0 */
    HAL_PWR_EnterSTANDBYMode();
}

Any one have any ideas why it is doing this?

5 REPLIES 5
Peter BENSCH
ST Employee

Please try:

void enter_standby(void){
	// clear the wake up flag
//	__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
 
	// display Stdby Mode on the OLED
	ssd1306_Fill(Black);			// clear the SSD1306 OLED display
	ssd1306_SetCursor(0, 0);
	ssd1306_WriteString("Stdby Mode ", Font_11x18, White);
	ssd1306_UpdateScreen();
 
	/* Disable WKUP pin */
	HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
 
       /* Clear PWR wake up Flag */
       __HAL_PWR_CLEAR_WAKEUP_FLAG(PWR_WAKEUP_PIN_FLAG1);
  
	/* Enable WKUP pin */
	HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
	/* Enter Standby Mode , wake up with a rising edge on PA0 */
    HAL_PWR_EnterSTANDBYMode();
}

Regards

/Peter

In order 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.

Thanks Peter. Will try this later. I'm sure this is the reason it keeps waking up without bringing the wakeup pin high.

Do I still need to check to see if the SB flag is reset ?

That was the issue. Thanks again.

Peter BENSCH
ST Employee

You are welcome.

Please keep in mind that there are tons of examples in your repository. So it always makes sense to browse there a little - my suggestion from above can also be found there.

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

/Peter

In order 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.