2024-09-18 07:32 AM - edited 2024-09-18 07:58 AM
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.
Solved! Go to Solution.
2024-10-10 12:34 AM
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.
2024-09-19 03:17 AM
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.
2024-10-10 12:34 AM
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.