AnsweredAssumed Answered

Unsuccessful entering in sleep mode and wait for interrupt for wakeup

Question asked by dan on Dec 10, 2015
Latest reply on Dec 10, 2015 by Clive One
Dear all,

I am using a STM32F103VEH micro-processor. I intend to put the processor into sleep mode and configure it so it will wake up by receiving any interrupt. I use the following code:

  uint32_t tmpreg = 0;

  tmpreg = PWR->CR;

  tmpreg &= CR_DS_MASK;

  tmpreg |= PWR_Regulator_LowPower;

  PWR->CR = tmpreg;

  // Ask the processor to sleep now.

  // Wait for any interrupt to wake up.

When a packet is received over UART and interrupt is triggered so I expect the processor to just operate normally, but the system will be just frozen when I run the code. When I remove "__WFI()" the system is not frozen anymore but I guess I need to have this command to wait for an interrupt to wake the processor up after a sleep.

Does anybody kno if I am doing anything wrong to put the processor into sleep mode and the expect it to be waken up when an interrupt is triggered?