Re: how to connect button to external interrputs of an AVR?

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
the problem with your design is that what is the voltage at the Int0 pin when
the switch is open? It's not connected to anything so there's no telling if the
voltage is high enough to not cause a reset.

Re: how to connect button to external interrputs of an AVR?
and the pin may not have current limiting appropriate to the design.  
Easier to use two resistors, one for current limit (the one connectoed
to the pin), and one to make a pull up (the one connectoed to vdd/vcc)
than to have to change the chip for problems associated.

Andrew

Gary Kato wrote:

Quoted text here. Click to load it


Re: how to connect button to external interrputs of an AVR?
you could use the on chip pull ups too. Just connect the button to the pin
and the other end to ground and presto. (But make sure you enable the pullup
in the software!)

int0 -------/(switch!)/------ GND

Quoted text here. Click to load it



Re: how to connect button to external interrputs of an AVR?
Quoted text here. Click to load it

See the 8515 Datasheet under I/O ports (page 62 in my copy).  When the
port is in input mode, you write a 1 value to the pin via the output
port.

Note: you write this to the *output* port address (e.g., PORTD), not the
input pin register (PIND).

Re: how to connect button to external interrputs of an AVR?

This circuit is likely to produce multiple interrupts due to the
pushbutton ringing. The good way to avoid it will be disabling
interrupts for about 50msec after the very first interrupt.
 
Vladimir Vassilevsky, Ph.D.

DSP and Mixed Signal Design Consultant

http://www.abvolt.com




Brett wrote:
Quoted text here. Click to load it

Re: how to connect button to external interrputs of an AVR?
Quoted text here. Click to load it

When the button is released in this diagram, the voltage potential on
the pin doesn't necessarily become ground.  It 'floats' up and down, and
can be influenced by nearby signals, noise, etc, causing false triggers
and other problems.  This is fixed with a resistor on the MCU pin that
bleeds off the voltage to ground.  The lower the value, the faster the
transition (and the greater the power draw when the button is pressed).

The AVR series have pull-ups in the MCU (that raise the potential to
Vcc), so I'm curious why the AVRfreaks example is suggesting an external
pull-up.  Maybe for simplicity of the tutorial?  It'd be worth asking
them.

For inputs, I've seen inline resistors recommended more in the context
of protecting against static discharge from the user's finger.  For
outputs they're needed to keep the LED, etc. from drawing too much
current from the MCU.  Or perhaps as a precaution against you
accidentally enabling the port as an output and then pressing the
button.

For a simple experimenter, you could get by with just the external
pushbutton to ground, by using the internal MCU pull-up.  In the AVR,
it's a matter of writing a value to the port register when it's in input
mode.  The 8515 datasheet explains it in detail.

'Debouncing' is a topic you may want to read up on.  Your ISR won't fire
just when the button is released (on the rising edge) - it'll fire many
times for one button push.

Re: how to connect button to external interrputs of an AVR?
Quoted text here. Click to load it

The first and second examples have a pullup resistor so that when the
switch is open, the input is pulled to a known high state. This might
or might not be mandatory depending on the characteristics of the pin.

The first example also has a current-limiting resistor to reduce power
consumption when the switch is closed. This would also provide some
sanity-checking against, for instance, code that has configured the
pin as an open-source LOW output.

Site Timeline