cancel
Showing results for 
Search instead for 
Did you mean: 

stm32H73** sleep mode

harareyd
Associate

Hi, 

My test board can enter sleep mode OK, but doesn't wake up when PC13 goes high: (never reach __enable_irq())

 

 

void Sleep() {
__disable_irq();

SysTick->CTRL = 0;

// Enable WKUP4 (PC13)
PWR->WKUPEPR = PWR_WKUPEPR_WKUPEN4; // Enable WKUP4
PWR->WKUPCR = 0xFFFFFFFF; // Clear all wake-up flags

SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
PWR->CR1 |= PWR_CR1_LPDS; // Low Power Deep Sleep

__DSB();
__ISB();
__WFI(); // Enter deep sleep

__enable_irq();
}

 

 
 
3 REPLIES 3
Sarra.S
ST Employee

Hello @harareyd, welcome to the ST community,

Consider using __WFE() instead of __WFI() to enter sleep mode. The __WFE() instruction can be more suitable for event-driven wake-up scenarios.

But your code is correct... maybe the issue is with the physical button! could you test it? 

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 am not much oriented in sleep modes, but it looks like you go to sleep with disabled interrupts.

When using __WFE() the board doesn't enter sleep mode at all unfortunately. It just skips right over the __WFE() instruction. I verified that the input is working. Sleep() is called when PC13 goes low.