cancel
Showing results for 
Search instead for 
Did you mean: 

procedure for enter/exit STOP mode with one EXTI line interrupt

beppe2
Associate
Posted on November 26, 2009 at 04:49

procedure for enter/exit STOP mode with one EXTI line interrupt

1 REPLY 1
beppe2
Associate
Posted on May 17, 2011 at 13:31

Hi all,

i am trying to enter and exit STOP mode PWR_EnterSTOPMode within a EXTI line connected to an external button (GPIO).

The behavior i'd like to have is a single button that when pressed goes into STOP and when pressed again wake up and generate a system reset.

unfortunately i cannot find a way to make it work, and the posts here do not solve my problems. :(

with PWR_STOPEntry_WFI, i cannot exit from Stop mode. with PWR_STOPEntry_WFE it goes in hard fault when i press the button the second time to wake it up. could someone explain the basic procedure to make it work?

here is the relevant code:

-----------SETUP:

NVIC_InitTypeDef NVIC_InitStructure;

EXTI_InitTypeDef EXTI_InitStructure;

GPIO_InitTypeDef GPIO_InitStructure;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

GPIO_Init(GPIOE, &GPIO_InitStructure);

GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_PinSource3);

EXTI_InitStructure.EXTI_Line = EXTI_Line3;

EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;

EXTI_InitStructure.EXTI_LineCmd = ENABLE;

EXTI_Init(&EXTI_InitStructure);

NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQChannel;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

-----------in ISR:

void EXTI3_IRQHandler(void)

{

EXTI_InitTypeDef EXTI_InitStructure;

if(EXTI_GetITStatus(EXTI_Line3) != RESET)

{

EXTI_ClearITPendingBit(EXTI_Line3);

GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_PinSource3);

EXTI_InitStructure.EXTI_Line = EXTI_Line3;

EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Event;

EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;

EXTI_InitStructure.EXTI_LineCmd = ENABLE;

EXTI_Init(&EXTI_InitStructure);

PWR_EnterSTOPMode(PWR_Regulator_ON, PWR_STOPEntry_WFE);

NVIC_GenerateSystemReset();

}

what am i missing?

Thank you!