2021-06-20 10:42 PM
Hello!
I have a question about power supply and ON/OFF capabilities of microcontroller.
Normally, When power supply is turned ON, the microcontroller Start executing the program.
In my case I want that after Power supply is turn ON, the microcontroller have power but not executing the program code. With powerON button I will start the program (like it is in the computer).
In short word. I want to turn ON the microcontroller with the button, like PC.
Is there any elegant solution for the problem written above?
All the best,
Domen
2021-06-20 11:13 PM
Hello Dlvan
At stage of board power on keep the reset pin to low by using on/off switch. When you want to run the code just make the reset pin high by using on/off switch.
2021-06-20 11:29 PM
Like it enters Standby and you Wake it?
2021-06-20 11:34 PM
Yes, something like this.
2021-06-21 12:49 AM
In "int main(void)" function i write:
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN5);
HAL_PWR_EnterSTANDBYMode();
But after I press the button on Power wakeup pin5, the microcontroller don't go to main program (while loop).
Any idea?
Thank you a lot.
2021-06-21 05:19 AM
On powerup you may need to wait till the input signal is stable.
So before the EnableWake, do a loop that waits till the PIN has been in non-wake state for several samples.
Do you have any debounce on the switch input? A capacitor may take time to ramp up/down depending on resistor size.
Write some code to sample to read the input to an array many times at powerup (array[1000] and then put breakpoint and look at how many cycles it takes for pin to stabilize. If just using a delay then wait double that time to be safe (temperature and component aging variations)
(The world of digital - isn't always very digital)
Paul