Is it possible to use a button as both an I/O input and external interrupt?

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would like my system to awaken from a sleep mode by pressing any one of two available buttons on the front. These buttons also serve as inputs when the system is awake.

 

Would it be possible to configure these buttons to serve this dual purpose?

 

My initial reaction is to run the INTx pin and the I/O pin both through the button to ground (i.e. the button is configured for pull-up pins).

 

Which brings me to my next question: Are interrupt pins configured as pull-up or pull-down?

 

Thanks in advance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is very common in fact. You would often use INTn or PCINT from a button simply as the wakeup source from SLEEP but once the AVR awakes that interrupt source may be disabled (until next time, just before you sleep) and instead some kind of timer interrupt polling for debounce mechanism takes over to scan the button while awake.

 

As for pull-up/down that is up to you but note that for many AVRs, when using INTn (not PCINT) it can only be used to wake up for a "low level" so its  inactive stated would want to be high. If this is a "modern" AVR (like the last decade) it should also offer PCINTs. These are a "better" wake up source and will activate on any transition (so it could be high-low or low-high).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Connect your button from the port pin to gnd, use either the internal pullup or use an external pull up resistor(10k) to vcc. 

Then,  your logic will be if PIN is LOW, button is active, if HIGH then button is in-active.

 

Jim