cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to wake-up from stand-by using pin wake-up

bivin mato
Associate III

Hello,

I'm using STM32F779NI.

I'm trying to enter Standby mode & would like to wake-up through pin wake-up (PC13).

Looks like stand-by entry is happening fine (SBF is set post reset) but wake-up pin flag is not set.

Please find the code as below

int main(void)
{
	/* Add your application code here */
	__IO uint32_t tmpreg;
 
	/* Enable clock for toggle LED */
	SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOIEN);
	tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOIEN);
 
	/* Enable clock for toggle LED */
	SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOJEN);
	tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOJEN);
 
	/* Enable clock for PWR module */
	SET_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);
    tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);
 
	/* Configure toggle LED */
	GPIOI->MODER |= GPIO_MODER_MODER15_0;
	GPIOI->PUPDR |= GPIO_PUPDR_PUPDR15_0;
	GPIOI->OSPEEDR |= GPIO_OSPEEDR_OSPEEDR15;
	GPIOI->BSRR= GPIO_BSRR_BS15; // Reset
 
	/* Configure toggle LED 1 */
	GPIOJ->MODER |= GPIO_MODER_MODER0_0;
	GPIOJ->PUPDR |= GPIO_PUPDR_PUPDR0_0;
	GPIOJ->OSPEEDR |= GPIO_OSPEEDR_OSPEEDR0;
	GPIOJ->BSRR= GPIO_BSRR_BS0; // Reset
 
	if( (READ_BIT(PWR->CSR1,PWR_CSR1_SBF)) == PWR_CSR1_SBF)
	{
		GPIOI->BSRR= GPIO_BSRR_BR15; // Set
 
		if( (READ_BIT(PWR->CSR2,PWR_CSR2_WUPF4)) == PWR_CSR2_WUPF4)
		{
			GPIOJ->BSRR= GPIO_BSRR_BR0; // Set
		}
	}
 
	/* Set SLEEPDEEP bit of Cortex System Control Register */
	SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
 
	/* Enable standby mode */
	SET_BIT(PWR->CR1, PWR_CR1_PDDS);
 
	// Clear WUF flag
	SET_BIT(PWR->CR2, PWR_CR2_CWUPF4);
 
	// Enable appropriate wake-up pin
	SET_BIT(PWR->CR2, PWR_CR2_WUPP4);
	SET_BIT(PWR->CSR2, PWR_CSR2_EWUP4);
 
	/* Ensure that all instructions done before entering SLEEP mode */
	__DSB();
	__ISB();
 
	/* Request Wait For Interrupt */
	__WFI();
 
}

Regards,

Bivin

3 REPLIES 3
bivin mato
Associate III

@TDK​ any inputs ?

I don't have a ton of experience with low-power modes or with the F7. I looked through the post and couldn't find anything wrong. I'm a little confused why your main() function ends with __WFI(); I would have expected you to be checking flags after this. main() should never return, although typically there's a while loop outside of that and it's not an issue. Maybe I'm missing something.

Here's an example from CubeMX repository. Seems to be doing roughly what you are. Might want to double check:

https://github.com/STMicroelectronics/STM32CubeF7/blob/3600603267ebc7da619f50542e99bbdfd7e35f4a/Projects/STM32F767ZI-Nucleo/Examples_LL/PWR/PWR_EnterStandbyMode/Src/main.c

If you feel a post has answered your question, please click "Accept as Solution".

Thanks @TDK​ .

That's because the low power mode which i'm attempting is stand-by. Wake up from stand-by is similar to that of a reset ( will start from reset vector). Only for other low power modes (sleep, stop), the resumption happens from the point from where the low power was entered.

However keeping an infinite while at the end is a good practice.

I will see if this example helps.

Regards,

Bivin