2015-06-22 11:09 PM
Hi everyone,
I'm trying to write code that : 1) Enter STOP mode every falling of specific EXTi pin. 2) Wake up every rising of this pin.This is my code :
void
EnterStopMode(void) { /* // ASSERT(false); // Code is not written yet */ PWR_VoltageScalingConfig(PWR_VoltageScaling_Range3); PWR_UltraLowPowerCmd(ENABLE); PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);}
/////////Interrupt routine : void EXTI4_IRQHandler(void) { /// Falling /// if(!(GPIOA->IDR & GPIO_Pin_4)) { EnterStopMode(); } /// Rising /// if(GPIOA->IDR & GPIO_Pin_4) { ///Test point/// ---> debug probe l_index^=1; GPIO_WriteBit(GPIOD,GPIO_Pin_10, (BitAction)l_index); ////////////////////////////// /////////////////////////////////// } // Clear the EXTI line 4 pending bit EXTI_ClearITPendingBit(EXTI_Line4); } /////////////////////////////////////////////////////////////////////// The device is entring stop mode ( I can see it using breakpoints ) , but it doesn't wake. It stuck there and i can't see any EXTi occur. Please advice.2015-06-23 04:55 AM
Try to first clear EXTI interrupt pending bit and try again.
2015-06-23 11:42 PM
You right ....but still it doesn't help.
Below is my new IRQh : void EXTI4_IRQHandler(void) { /// Falling /// if(!(GPIOA->IDR & GPIO_Pin_4)) { ///Test point/// ---> debug probe l_index^=1; GPIO_WriteBit(GPIOD,GPIO_Pin_10, (BitAction)l_index); ////////////////////////////// /////////////////////////////////// // Clear the EXTI line 4 pending bit EXTI_ClearITPendingBit(EXTI_Line4); EnterStopMode(); } /// Rising /// if(GPIOA->IDR & GPIO_Pin_4) { ///Test point/// ---> debug probe l_index^=1; GPIO_WriteBit(GPIOD,GPIO_Pin_10, (BitAction)l_index); ////////////////////////////// /////////////////////////////////// // Clear the EXTI line 4 pending bit EXTI_ClearITPendingBit(EXTI_Line4); } } I'm probe out to scope the debug pin ...so i can see if it toggle --> wake up