2023-04-14 01:57 AM
Hi,
I'm testing the standby mode with a clear projet with the leds are gpio output and the user button, PA0 (WKUP1 pin) as gpio input.
I figured out how go in the standby mode one time.
But after one wake up my nucleo trigger the wake up by itself.
It seems that PWR_FLAG_WU and PWR_FLAG_SB are cleared.
I'm using a wire linked between PA0 to GND to simulate a raising edge when i unplug it, as mentioned before, it works for the first iteration.
There is my code:
/* USER CODE BEGIN 2 */
HAL_Delay(2000);
if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET){
HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
}
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
while (1)
{
if(HAL_GPIO_ReadPin(USER_BUTTON_GPIO_Port, USER_BUTTON_Pin)==SET)
{
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
HAL_PWR_EnterSTANDBYMode();
}
HAL_GPIO_TogglePin(LD1_GPIO_Port, LD1_Pin);
HAL_Delay(500);
}
To be more precise to how i'm processing:
2023-04-14 03:26 AM
Hello @JAgue.1,
You need to make sure that the wake-up pin is disabled before toggling the LD2 LED. Otherwise, the wake-up flag might be set again and the MCU will wake up immediately which is happening in this case.
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-04-17 12:16 AM
Hello,
I tried to put the disabled like you did, then outside the if and then in the /*init*/ section but no one worked.
Did an action in other pin could trigger the wkup pin ?
2023-04-17 04:35 AM
Hello again @JAgue.1,
Yes, it's possible for other pins to trigger the wake-up pin. but you're enabling the specific wake-up pin using HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1),
So the wake-up PIN1 is disabled before toggling the LD1 LED and waiting for the button press. It's only enabled and cleared just before entering standby mode.
You can test this and monitor the PA0 pin using an oscilloscope or logic analyzer to see if there are any unexpected signals or noise. This way, we are sure that the wake-up pin is not triggered inadvertently by other signals.
And maybe try using different pin? or use an external interrupt controller to debounce the signal
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.