1
\$\begingroup\$

This is the IO port of ATMEGA328p according to 76 page of datasheet.

ATMEGA328p GPIO

As I know, Pull up is the most suitable system because lots of voltage spikes are logic 1.So, if we can give logic 1 normally, we can avoid unwanted triggering causes by spikes.

This thread has some explanation. But,it can't satisfy me.because ATMEGA328p port is bi-directional.

Explain what is the most suitable way(pull up/pull down) when we use a button input to the port with help of diagram above.

\$\endgroup\$
10
\$\begingroup\$

The ATmega328p I/O block only provides pull-up functionality. There is no internal pull-down. I've circled the relevant bit of the circuit in the diagram below -- notice that there is no "mirror" of this circuit to pull the pin to ground.

(It is, of course, still possible to drive the pin to a hard low. However, this is not suitable for use as a pull-down; the pin will always read as low if it is being driven low, and the I/O block may be damaged if it is forced to sink more than its limit of 40 mA from a pushbutton.)

If you disable the internal pull-up resistor, you can certainly hook up an external pull-down resistor. There is no significant advantage to doing so, though, especially for a low-speed I/O like a pushbutton.


ATmega328p I/O block, with pull-up circuit circled

\$\endgroup\$
8
\$\begingroup\$

Your premise that a pull-up is somehow less susceptible to noise has no grounding in fact.

With CMOS devices it really does not make much difference. The current required is pretty much the same for both a pull-down and a pull-up. TTL on the other hand requires a pull-down to sink a considerable amount of current. The latter is probably the main reason for the prevalence of pull-ups.

If the line is to be driven from another IO pin though, you should chose whichever side produces least load on the driving pin.

Generally the choice of which to use is more governed by the ensuing logic rather than the circuit requirement.

\$\endgroup\$
4
\$\begingroup\$

One factor to consider is that the input may be a switch or button located some distance from the circuitry. A pull down input requires the power supply rail be run out to the button. An accidental short to ground may blow a fuse. This might be preferable to the pull up behavior of the short operating the button but usually this is not the case.

You can add a resistor to the pull up power line, but this complicates the circuitry and slightly reduces noise immunity.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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