cancel
Showing results for 
Search instead for 
Did you mean: 

wakeup from sleep mode with uart interrupt

andrew_trowbridge
Associate
Posted on October 25, 2013 at 15:00

Hi everyone

I'm trying to put my STM32L1 into sleepmode and wake it up again with an uart interrupt. So I send it to sleep using:

PWR_EnterSleepMode(PWR_Regulator_ON,TRUE)

which works, but now it does not wake up when I send data through the uart. Does anyone know why? Is there some flag I need to set to allow the uart isr to wake my stm up?

Thanks!

#stm32-uart #stm32 #interrupts
4 REPLIES 4
Amel NASRI
ST Employee
Posted on October 31, 2013 at 10:54

Hi Stephen,

The second parameter for ''PWR_EnterSleepMode'' should be the instruction used to enter sleep mode (PWR_SLEEPEntry_WFI or PWR_SLEEPEntry_WFE).

Check this first.

-Mayla-

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.

andrew_trowbridge
Associate
Posted on November 17, 2013 at 15:58

Hi Mayla

Thanks for your reply! I've tried what you suggested. But the STM32 still won't wakeup. Here's my code:

    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

    /* Select the Voltage Range 2 */

    PWR_VoltageScalingConfig(PWR_VoltageScaling_Range2);

    PWR_EnterSleepMode(PWR_Regulator_ON,PWR_SLEEPEntry_WFI);

And this is how I configure the Uart interrupt:

  GPIO_InitTypeDef GPIO_InitStructure;

  EXTI_InitTypeDef EXTI_InitStructure;

  NVIC_InitTypeDef NVIC_InitStructure;

  

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

  

  /* Configure USART1 pins:  Rx ----------------------------*/

  GPIO_InitStructure.GPIO_Pin =  USARTx_RX_PIN;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_400KHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

  GPIO_Init(USARTx_TX_GPIO_PORT, &GPIO_InitStructure);

  

  /* Connect Button EXTI Line to uart rx line */

  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB,EXTI_PinSource7);

  

  /* Configure User Button and IDD_WakeUP EXTI line */

  EXTI_InitStructure.EXTI_Line = EXTI_Line7 ;  // PB7 for uart rx pin

  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;  

  EXTI_InitStructure.EXTI_LineCmd = ENABLE;

  EXTI_Init(&EXTI_InitStructure);

  

  /* Enable and set uart RX EXTI Interrupt to the lowest priority */

  NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn ;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure); 

Strange is that it does wakeup when I put it into Stop mode... Any ideas?

hakan23
Associate II
Posted on March 26, 2014 at 07:37

Hello Stephen

Any progress on this issue ??

I want to do the same thing

best regard

  Håkan

mattreed9
Associate II
Posted on May 06, 2016 at 22:26

The clock for the Uart is turned off when asleep.

For this to work (from what I have read) you need to run the Uart from the external low-speed clock - since that clock is not turned off when asleep.

But, that clock is slow, about the fastest Uart speed you can do is 1200.

-Matt