cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L152 - can't woke from stop mode

moran
Associate II
Posted on June 23, 2015 at 08:09

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.

2 REPLIES 2
tm3341
Associate II
Posted on June 23, 2015 at 13:55

Try to first clear EXTI interrupt pending bit and try again.

moran
Associate II
Posted on June 24, 2015 at 08:42

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