1
\$\begingroup\$

as more of a hobbyist than a pro I apologise if I'm asking the wrong questions, however I have been researching for a while and hoped Stack exchange might help.

I've read a few articles on low power cut off circuits and soft latching power circuits but im hoping to achieve something a little smarter.

Essentially I'd like a single button interface whereby pressing the button would power the circuit when in the off state, act as an input when the circuit is active then power down the circuit if held for say 3 seconds or more.

On a software level it's important the power down the chip using the micro controller (potentially by dropping a pin to ground connected to a transistor/mosfet) as I'd like to send a "power down" message before shutting down the circuit.

Is this possible?

Thanks in advance,

Chris

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

Yes, this is possible.

  • Use the long-hold to put the processor into sleep state.
  • Configure the same pin to wake from sleep.
  • While the processor is running you can use the pin as a standard input.
\$\endgroup\$
1
\$\begingroup\$

Yes it is possible. I am working on a similar thing. The logic that i used is as follows,

  1. Configure that particular pin as an interrupt pin. Configure it such that it is triggered on every transition of the signal (high to low and also low to high)
  2. In the ISR, start the timer and enable its interrupt. Set the period of the timer as per the requirement of the 'long hold' functionality. If the button is held for the longer than the period of the timer, timer interrupt is fired.
  3. Once the timer interrupt is fired make sure to turn off the timer and raise a flag indicating that the button is pressed for a longer time.

Regards

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.