AnsweredAssumed Answered

wake up from stop mode using GPIO

Question asked by Damiano Balzani on Mar 20, 2018
Latest reply on Mar 20, 2018 by Damiano Balzani

Hi everybody,

 

i'm tryng to wake up MCU STM32L051T6 from stop mode using a GPIO pin. The pin is PB4 on Rising edge.

 

This is the code:

 

void stopMode(void)
{
DBGMCU -> CR |= DBGMCU_CR_DBG_STOP;

 

RCC -> APB1ENR |= RCC_APB1ENR_PWREN;
RCC -> IOPENR |= RCC_IOPENR_GPIOAEN;

 

EXTI -> IMR |= EXTI_IMR_IM4;
EXTI -> RTSR |= EXTI_RTSR_TR4;

 

NVIC_SetPriority(EXTI4_15_IRQn, 0);
NVIC_EnableIRQ(EXTI4_15_IRQn);

 

PWR->CR |= PWR_CR_CWUF; // clear the WUF flag after 2 clock cycles
PWR->CR &= ~( PWR_CR_PDDS ); // Enter stop mode when the CPU enters deepsleep
RCC->CFGR |= RCC_CFGR_STOPWUCK; // HSI16 oscillator is wake-up from stop clock
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; // low-power mode = stop mode


__WFI(); // enter low-power mode
}

The isr never goes!

 

Can someboby help me?

Thanks

 

Damiano

Outcomes