cancel
Showing results for 
Search instead for 
Did you mean: 

WakeUp from STOP using an EXTI GPIO LINE

confalonieri
Associate II
Posted on November 19, 2014 at 17:07

I am having trouble to wake up the STM32F407 from the STOP condition using a GPIO EXTI line (PB 0).  

The same GPIO line is used when the STM32 is ON to switch it OFF (THIS WORKS PERFECTLY) and whenever it is OFF to Wake it Up (DOES NOT WORK).

The setup foresees to use the internal RTC to wake it up after 3' of inactivity.

The STM32F407 wake up after 3 minutes accordingly with the RTC setup but no matter to wake it up using the GPIO line.

The setup code follows:

 GPIO_InitStruct.Pin  = GPIO_PIN_0;

 GPIO_InitStruct.Mode  = GPIO_MODE_IT_RISING;

   GPIO_InitStruct.Pull  = GPIO_NOPULL;

   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

 __HAL_GPIO_EXTI_CLEAR_FLAG(GPIO_PIN_0);

 NVIC_ClearPendingIRQ(EXTI0_IRQn);

 HAL_NVIC_SetPriority(EXTI0_IRQn, 2, 0);

 HAL_NVIC_EnableIRQ(EXTI0_IRQn);

HAL_PWREx_EnableFlashPowerDown();

 HAL_Delay(100);

 HAL_SuspendTick();

 HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON,PWR_STOPENTRY_WFI);

This is the registers values captured just before entering in STOP mode

IMR[00020001] EMR[00000000] RTSR[00020001] FTSR[00000000] EXTICR[00000001]

Any suggestion is welcome.

2 REPLIES 2
muhammaduzairafzal45
Associate III
Posted on November 21, 2014 at 06:02

/**

  * @brief  Configures system clock after wake-up from STOP: enable HSE, PLL

  *         and select PLL as system clock source.

  * @param  None

  * @retval None

  */

void SYSCLKConfig_STOP(void)

{

  /* After wake-up from STOP reconfigure the system clock */

  /* Enable HSE */

  RCC_HSEConfig(RCC_HSE_ON);

  

  /* Wait till HSE is ready */

  while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET)

  {}

  

  /* Enable PLL */

  RCC_PLLCmd(ENABLE);

  

  /* Wait till PLL is ready */

  while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)

  {}

  

  /* Select PLL as system clock source */

  RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

  

  /* Wait till PLL is used as system clock source */

  while (RCC_GetSYSCLKSource() != 0x08)

  {}

}

PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);

/* Configures system clock after wake-up from STOP: enable HSE, PLL and select 

       PLL as system clock source (HSE and PLL are disabled in STOP mode) */

SYSCLKConfig_STOP();

Have you enabled HSE,PLL etc after wakeup. Have you declared EXTI0_IRQHandler?
confalonieri
Associate II
Posted on November 21, 2014 at 12:24

Thanks, for the suggestion about the clock recovering. I will try it.

Anyhow, from the power supply current monitored while the EXTIO line is raised up I think that the micro does not try to exit from the stop condition !?

Yes I have declared and developed an IRQ handler dedicated for the EXTI0 line.

thanks again