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

asked Feb 7, 2016 at 14:18
\$\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.
answered Feb 7, 2016 at 14:22
\$\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

answered Feb 7, 2016 at 14:46
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.