Skip to main content
Associate II
April 4, 2025
Question

STOP2 Mode

  • April 4, 2025
  • 2 replies
  • 793 views

HLO

I am using STOP2 Mode in my controller is stm32l496 series it entering the stop2 mode but it's not coming out for waking up i use external interrupt .

interrupt is generating before entering stop2 mode but it not generated after the stop2 mode.

what is the problem.

 

HAL_SuspendTick();

// Optional: clear EXTI pending bit
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_0); // Replace with your EXTI pin

// Go to STOP2
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);

// Restore clocks
SystemClock_Config();

// Re-initialize GPIOs including EXTI pin
SystemReInit(); // or reconfigure the EXTI pin here manually

HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, SET); // Debug
HAL_ResumeTick();

 

void EXTI0_IRQHandler(void)
{
 /* USER CODE BEGIN EXTI0_IRQn 0 */

 /* USER CODE END EXTI0_IRQn 0 */
 HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
 /* USER CODE BEGIN EXTI0_IRQn 1 */

 /* USER CODE END EXTI0_IRQn 1 */
}

Code formatting applied - please see How to insert source code for future reference.

2 replies

Andrew Neil
Super User
April 4, 2025

Welcome to the forum.

For best results (including how to properly post source code), please see: How to write your question to maximize your chances to find a solution.

 


@Chintu wrote:

interrupt is generating before entering stop2 mode but it not generated after the stop2 mode.

what is the problem.


Have you enabled the pin in STOP2 ?

 

AndrewNeil_0-1743753653370.png

https://www.st.com/resource/en/datasheet/stm32l496ag.pdf#page=34

via: https://www.st.com/en/microcontrollers-microprocessors/stm32l496ag.html#documentation

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
ChintuAuthor
Associate II
April 4, 2025

Have you enabled the pin in STOP2 ?

yes i did.

/*Configure GPIO pin : PE0 */
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

Screenshot 2025-04-04 141104.pngScreenshot 2025-04-04 141131.png

Andrew Neil
Super User
April 4, 2025
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
ChintuAuthor
Associate II
April 4, 2025

Merged from separate thread.


void PowerDownUp(uint8_t Powermode)
{
//	HAL_SuspendTick();
//
//	PowerDown_GPIO_Deinit();
////		GPIO_InitTypeDef GPIO_InitStruct = {0};
////
//		__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF2);
////
////
////
////		HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2_HIGH);
////
//		HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
//
//
//
////================ Init Modules===================================================//
//
////	SystemReInit();
//		SystemClock_Config();
//
//		HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, SET);
//		HAL_ResumeTick();

	__HAL_RCC_SYSCFG_CLK_ENABLE();

 HAL_SuspendTick();

 // Optional: clear EXTI pending bit
 __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_0); // Replace with your EXTI pin
 EXTI->IMR1 |= EXTI_IMR1_IM0;
 // Go to STOP2
 HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);

 // Restore clocks
 SystemClock_Config();

 // Re-initialize GPIOs including EXTI pin
 SystemReInit(); // or reconfigure the EXTI pin here manually

 HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, SET); // Debug
 HAL_ResumeTick();
}

 

mƎALLEm
Technical Moderator
April 4, 2025

Hello @Chintu and welcome to the community,

You posted your thread in the wrong forum (I've moved it to STM32 MCU products forum board).

Could you please provide details on your issue?

See how to post a thread in the community: How to write your question to maximize your chances to find a solution

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.