cancel
Showing results for 
Search instead for 
Did you mean: 

WFI only works during debugging

mauromarz
Associate

Hi everyone!

I have this code where the mcu goes into STOP3 mode, and is waked up by a button triggering a wake-up pin.

But it only works in debug. Without the debugger, the mcu immediately exits WFI.

In debug, when I execute che code, the user led turns on, the mcu enters WFI, I press the wake-up button, the mcu exits WFI and the user led turns off.
Without debug, when I execute the code the user led just flashes for a fraction of a second, turning on and off immediately:

HAL_GPIO_WritePin(GPIOH, GPIO_PIN_0, GPIO_PIN_SET);

HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN7_HIGH_0);
HAL_SuspendTick();
HAL_PWREx_EnterSTOP3Mode(PWR_STOPENTRY_WFI);
SystemClock_Config();
HAL_ResumeTick();

HAL_GPIO_WritePin(GPIOH, GPIO_PIN_0, GPIO_PIN_RESET);

I also tried to put the user led on/off code around the WFI instruction inside HAL_PWREx_EnterSTOP3Mode(), and the behaviour is the same.

This is the empty callback for the wake-up pin, redefined in main.c

void HAL_PWREx_S3WUCallback(uint32_t WakeUpPin)
{
}

What can I do?

 

Thanks!

0 REPLIES 0