cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 reboots right after standby if WAKEUP line is high

arro239
Senior

I have stm32f4 standby which works as expected if wakeup PA0 is low - my mcu wakes up once I apply high to PA0

I have the problem if PA0 line is constantly high I get wake up right after standby. My understanding is it's supposed to wait for rising edge and not wake up on high level if it was there the moment of standby call? Datasheet says "The device exits the Standby mode when" ... "rising edge on the WKUP pin occurs."

PWR_CR_CWUF might be relevant and I do clear it yet things are not the way I expect those.

How can I fix my code to work as desired only on rising edge or is MCU behaving as expected based on high level regardless of edges?

	// Don't get bothered by interrupts
	__disable_irq();
 
	SysTick->CTRL = 0;
	SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
	PWR->CR |= PWR_CR_PDDS;	// PDDS = use standby mode (not stop mode)
	PWR->CR |= PWR_CR_CSBF;	// Clear standby flag
 
	//Enable Wakeup Pin for PA0
	PWR->CSR |= PWR_CSR_EWUP;
 
	// Clear wakeup flag - it may be set if PA0 is already
	// high when we enable it as a wake source
	PWR->CR |= PWR_CR_CWUF; //Clear Wakeup Pin flag for PA0
 
	__WFI();

2 REPLIES 2
Peter BENSCH
ST Employee

Well, it could be that you have a pending interrupt when you set PWR_CSR_EWUP so it looks like the wakeup fires immediately. Perhaps it would make sense to exchange lines 10 and 14 to clear first and then enable:

// Clear wakeup flag - it may be set if PA0 is already
// high when we enable it as a wake source
PWR->CR |= PWR_CR_CWUF; //Clear Wakeup Pin flag for PA0
 
//Enable Wakeup Pin for PA0
PWR->CSR |= PWR_CSR_EWUP;

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.

I've tried with the proposed different order of instructions but no changes in outcome - still auto-reboot if I supply constant 5v