Skip to main content
Associate II
Jul 19, 2026 9:48 AM UTC
Question

STM32L051 sometime do not exit from stop mode.

Post edited by ST moderator for the code. 

Hi,
I have a pre-production batch of about 80 STM32L051 custom boards.
Under certain circumstances, the microcontroller goes into sleep mode and waits for an IRQ to restart.
Of these 80 boards, about 10 randomly, after going into sleep mode, don't restart (until a reset).
This is the code I use:

__HAL_GPIO_EXTI_CLEAR_IT( VIB_SENS_MAIN_Pin);
__HAL_GPIO_EXTI_CLEAR_IT( VIB_SENS_BACKUP_Pin);

NVIC_EnableIRQ( EXTI4_15_IRQn);
HAL_COMP_Stop_IT( &hcomp1);
HAL_COMP_Stop_IT( &hcomp2);

__disable_irq();
__HAL_PWR_CLEAR_FLAG( PWR_FLAG_WU);
__HAL_GPIO_EXTI_CLEAR_IT( VIB_SENS_MAIN_Pin);
__HAL_GPIO_EXTI_CLEAR_IT( VIB_SENS_BACKUP_Pin);
__HAL_COMP_COMP1_EXTI_CLEAR_FLAG();
__HAL_COMP_COMP2_EXTI_CLEAR_FLAG();
delay_us( 5);

HAL_SuspendTick();
HAL_PWR_EnterSTOPMode( PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);

HAL_NVIC_SystemReset();

What did I do wrong?

Thanks for the suggestion.

 

2 replies

UfoitAuthor
Associate II
Jul 19, 2026 11:32 AM UTC

Forget about this.
It looks like a hardware design issue that I need to have re-checked.
Thanks.

mƎALLEm
ST Technical Moderator
Jul 20, 2026 8:38 AM UTC

Hello ​@Ufoit ,

In next time please use code button to paste a code :

When you started this post, did you see this pop-up?

PS: I’ve edited your post.

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