Skip to main content
Visitor II
March 21, 2024
Question

STM32U535NEY6Q: STOP Mode

  • March 21, 2024
  • 1 reply
  • 674 views
For going to sleep with STM32U535NEY6Q with the following example:
 
``` c
int main(void) {
    HAL_Init();
    SystemClock_Config();
    MX_GPIO_Init();
    // ^ // Configure GPIO pin : INT_BUTTON_Pin
    // | GPIO_InitStruct.Pin = INT_BUTTON_Pin;
    // | GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
    // | GPIO_InitStruct.Pull = GPIO_NOPULL;
    // | HAL_GPIO_Init(INT_BUTTON_GPIO_Port, &GPIO_InitStruct);
 
    while(1) {
    DEBUG_PRINTF("%d SLEEP\n", HAL_GetTick());
    HAL_Delay(100);
 
        HAL_PWREx_EnableUltraLowPowerMode();
        __HAL_PWR_CLEAR_FLAG(PWR_FLAG_STOPF);
        __HAL_RCC_PWR_CLK_ENABLE();
        HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
 
        DEBUG_PRINTF("%d WOKEUP %x\n", HAL_GetTick(), HAL_GPIO_ReadPin(INT_BUTTON_GPIO_Port, INT_BUTTON_Pin));
        HAL_Delay(200);
    }
}
```
 
Causes it to not go to sleep as such:
 
```
4045 SLEEP
4148 WOKEUP 0
4351 SLEEP
4453 WOKEUP 0
4656 SLEEP
4758 WOKEUP 0
```
 
Current knowledge base is I'm treating it as if it were STM32L071KZU3. Reasonable assumption is that there's some PWR/RCC step I'm missing or not clearing, so inquiring on what obvious mistake is being made. Only one EXTI pin set.

 

    1 reply

    ST Employee
    April 18, 2024

    Hello @Ed_

    I would suspect there are other wake-up sources 

    add  HAL_SuspendTick(); before entering sleep or stop2 mode and resume the tick interrupt after 

     

    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.