2009-11-25 07:49 PM
procedure for enter/exit STOP mode with one EXTI line interrupt
2011-05-17 04:31 AM
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!