cancel
Showing results for 
Search instead for 
Did you mean: 

Problem when I am waking-up from standby mode (STM32L4)

GR88_gregni
Associate II

Hello, I am trying to set the device into standby mode before the actual code execution. I have set a pin as a wake-up source from standby mode and I need to run the actual code after waking up from standby mode. The workflow seems to work, for instance it goes to standby mode and when an interrupt comes from the pin the system wakes-up and starts the actual code execution. When it comes to enable a pin with HAL_GPIO_WritePin then the system crashes and it reset again. This is causing a loop of standby mode and wake up event which I don't want. I need the standby to run only once before the actual code. So for that I use this code: 

 

1) It enters into the standby mode since the check_reset_source returns 0 from the first execution of the program

2) Then an interrupt comes to the pin and the system wakes-up from standby mode.

3) It starts again  and after peripheral initialization check_reset_source returns 1 and then it goes to the actual code execution.

4) When the init_test_code starts there is a line where the HAL_GPIO_WritePin sets high a specific pin then it resets (I don't know the reason for that), runs the check_reset_source, which returns 0 and then goes back to standby mode. 

 

How to avoid that? Does anyone know the reason or can give some hints to resolve this issue? 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Thank you for your reply! Well my problem was not that, I was reconfiguring the GPIOs after resuming from standby however, I had an external modem connected to my custom PCB that when I enable it it was consuming enough current to make my microcontroller force reset. I solved this issue by adding a capacitor. 

View solution in original post

2 REPLIES 2
Sarra.S
ST Employee

Hello @GR88_gregni, Welcome to the Community, 

After waking up from standby mode, all peripherals, including GPIOs, need to be re-initialized, because the standby mode typically results in the loss of peripheral states. So, the GPIOs need to be reconfigured before calling HAL_GPIO_WritePin

Also, after waking up from standby mode, clear the wakeup flags 

Otherwise, maybe you can share a relevant code sequence to spot the problem 

 

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.

Thank you for your reply! Well my problem was not that, I was reconfiguring the GPIOs after resuming from standby however, I had an external modem connected to my custom PCB that when I enable it it was consuming enough current to make my microcontroller force reset. I solved this issue by adding a capacitor.