0
\$\begingroup\$

As the title states, can the function EXTI_GenerateSWInterrupt() wake up the processor after it is put into a low-power mode using the PWR_EnterSTOPMode() function? The documentation says that an EXTI interrupt can wake up the processor from Stop Mode, but I have not had any luck. Here is how I am setting up the EXTI and NVIC:

EXTI_InitTypeDef EXTI_Init_Struct;
NVIC_InitTypeDef NVIC_InitStructure;

EXTI_Init_Struct.EXTI_Line = EXTI_Line0;
EXTI_Init_Struct.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_Init_Struct.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_Init_Struct.EXTI_LineCmd = ENABLE;

EXTI_Init(&EXTI_Init_Struct);

/*
some code
*/

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);

/*
   more code
*/
static int power = 1;
static int stopMode = 0;
//main loop
while(1)
{
    if(power)
    {
        //this is just a test timer to shut down after 5 seconds
        if(ElapsedTimeLowRes(stopMode) >= FIVE_SECOND)
        {
            PWR_EnterSTOPMode(PWR_Regulator_LowPower , PWR_STOPEntry_WFI);
            power = 0;
        }
    }
    else
    {
        EXTI_GenerateSWInterrupt(EXTI_Line0);
        stopMode = 0;
        power = 1;
    }
}

Now, I would think that as soon as the EXTI_GenerateSWInterrupt function is called in this case, the processor would wake back up almost instantly since it is being called in the next iteration of the loop after being put into Stop Mode. This is not the case however. The processor remains in Stop Mode. Any thoughts?

Note: This is just "test" code until I figure out how to wake-up the processor. I know I could use an RTC timer to wake the processor up, but the processor could be asleep anywhere from a few seconds to over an hour.

Thanks in advance.

\$\endgroup\$
0

1 Answer 1

3
\$\begingroup\$

can the function EXTI_GenerateSWInterrupt() wake up the processor after it is put into a low-power mode using the PWR_EnterSTOPMode() function?

The answer is simple: No!

The MCU core does not execute any instructions in Stop Mode, and hence cannot run any function.

\$\endgroup\$
2
  • \$\begingroup\$ OK, that's all I needed to know. I was figuring as much. Thanks! \$\endgroup\$
    – Josh
    Nov 25, 2014 at 14:53
  • \$\begingroup\$ I imagine this would be the same case for using Sleep Mode (WFI function) as well? \$\endgroup\$
    – Josh
    Nov 25, 2014 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.