cancel
Showing results for 
Search instead for 
Did you mean: 

How to Turn ON the STM32 with button?

DIvan.1
Associate III

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

This discussion is locked. Please start a new topic to ask your question.
5 REPLIES 5
srikanth
Associate III

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.

Like it enters Standby and you Wake it?​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Yes, something like this.

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.

Paul1
Lead

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