cancel
Showing results for 
Search instead for 
Did you mean: 

Not waking up from stop3 mode immediately after Programming STM32 controller

mohan-ltts
Associate II

I am working with STM32 U575/U5A5 series of STM32 controllers in low power mode. I have programmed the controller to enter into Stop 3 mode and wake from stop3 mode based on wakeup Pin(High on PF2). With this implementation issue what we observed is once immediately flashing hex file into controller using STlink programmer, Controller is entering in stop3 mode but it is not waking up from stop3 mode even after low to high transistion on wakeUp pin(PF2). If I remove the power and connect it back, it is working as expected enterning into stop mode 3 and waking up from stop mode 3 on low to high transistion on wakeUp pin(PF2) all the time. 

The question here is why for the first time after flashing hex file into controller, entering into stop3 mode but not waking up from stop3 mode and requires power reset?

low power mode is configured as follows:

void LowPowerInit()
{    
    LL_RCC_SetClkAfterWakeFromStop(RCC_STOP_WAKEUPCLOCK_SELECTED);
    __HAL_RCC_PWR_CLK_ENABLE();    
    HAL_PWREx_EnableUltraLowPowerMode();
 
    //Selecting USB select pin(PF2) as wakeup source.
    HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN8_HIGH_0);
 
    NVIC_ClearPendingIRQ(EXTI2_IRQn);
    HAL_NVIC_SetPriority(EXTI2_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(EXTI2_IRQn);
 
    EnterStop3Mode();
}
 
void EnterStop3Mode()
{     
    HAL_PWREx_EnterSTOP3Mode(PWR_STOPENTRY_WFI);    
    SystemClockConfig();
 
    LL_LPM_DisableSleepOnExit();
    LL_PWR_ClearFlag_WU();
    LL_PWR_ClearFlag_STOP();
    LL_PWR_ClearFlag_SB();
    irq_unlock(0);
}
24 REPLIES 24
Sarra.S
ST Employee

Hello everyone, 

I’ve moved the last comment of @mohan-ltts which wasn’t directly related to the initial post (Separate thread link: Issue to wake up from stop 3 mode when migrating fr... - STMicroelectronics Community

However, to conclude this discussion, the issue is resolved when suspending SysTick before entering stop 3 mode.

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.

Hello,

I continued further checking. Tried things as suggested by ST team in forum (i.e. checking with LPMODE_RTC code and ST cube examples). Herewith few observations. Some of the observation are little different than earlier reported.

 

I use ST Cube programmer for board flashing. After flashing the code I keep it connected.
In the example code (modified), when MCU enters in to STOP 3 mode, ST cube programmer connection gets disconnected.
I don't see same behavior (i.e. ST cube programmer connection break) with older code base and ST Cube low power sample code.

Behavior with 2.17 cube programmer and earlier one is same. It seems to me issue it is not ST cube programmer related.

Then I modified firmware to make it enter in to STOP 2 mode (instead of STOP 3), it works fine as expected i.e. MCU is coming out of sleep mode on system reset and RTC timeout.

Note: As reported at start of the thread this issue is occurring only first time after flash programming.

Wondering in new code base when MCU enters in to STOP 3 mode is connection break with ST cube programmer is acceptable behavior or not. If it is not then does it give any clue what could be wrong with new code base as same thing is not happening with older code base and with ST cube example. 

Please let me know if any additional details are needed. Appreciate for any inputs which could help for debugging further. Thank you. 

 

Hello,

We added code to SuspendTick, set S3WU interrupt before entry to stop 3 mode and resuming tick after invoking stop 3 function as suggested in sample code. It did not help but. Please suggest what else can be checked.

We have two use cases: First use case is Stop 3 entry on external pin trigger (GPIO) on USB power removal and wake up when USB power connection is back. Second use case is wake up on RTC timeout. 

Regarding first use case: When USB power is removed and module enters in to sleep mode I see brown out is detected. Will that cause any issue in wake up from STOP 3?

Also request ST team to provide link to STOP 3 mode entry and exit with extern interrupt (GPIO) pin. 

 

Thanks

 

 

 

Hello @devfwtest 

Wakeup from STOP3 mode cannot be performed by EXTI interrupt. You need to configure a wakeup pin as mentioned in the reference manual

Saket_Om_0-1742288207651.png

Please look at the example code below to set your wakeup pin :

  /* Enable WKUP pin */
  __HAL_RCC_PWR_CLK_ENABLE();
  HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2_HIGH_1);
  __HAL_PWR_CLEAR_FLAG(PWR_WAKEUP_FLAG2);

 

 

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

Thank you for reply.

Adding few comments for better clarity.

In our case, external pin trigger I mean we are using PF2 which is configured as a Wake up source.

I tried suggested code changes in to ST cube example (PWR_STANDBY) also modified code little bit to make entry in to STOP 3 mode instead of STANDBY. Verified it on Nucleo-U575ZI-Q eval board.

I could see it is working fine i.e. device enters in STOP3 (checked with current measurement) and wakes up with button press.

(For your information, after first time flash if I reset device without removing USB power to make it enter in to STOP 3 mode, current consumption in STOP shows little higher than STOP 3 entries after USB power removal. For sake of simplicity of conversation, not concern about this behavior for time being.)

 

When I am checking similar code implementation (referring working ST cube example) in our device with product firmware (Zephyr RTOS base application with HAL API for power saving mode), it is not working as expected i.e. device is not waking up (first time after MCU flash).

One point to highlight, in product we have STM32U5A5 MCU (whereas in eval board we have STM32U575). Not sure if it will make any difference.

Please advise.