There are three states within each gpio: pull up, pull down, and no pull.
When do you need to choose to pull up, pull down or not pull up?
If it is output, then usually choose no pull, so that the pin can output correctly according to your output data. 2. If it’s input, then you need to look at the default input value of the specific application is 0 or 1. .
1. If it is output, then usually choose no pull, so that the pin can output correctly according to your output data.
2. If it’s input, then you need to look at the default input value of the specific application is 0 or 1. .
2.1 If the default is to enter 0, it is best to configure it as pull down and vice versa.
The main reason for doing this is for the uncertainty of the external circuitry in the absence of a pull up/down. There are many hardware engineers who design circuits with pull-up and pull-down resistors on the outside of the GPIO port, which is the same purpose as configuring pull up/down internally, and has the same effect.
3. Examples
PULLUP & PULLDOWN for the input mode, for example, we have a microcontroller I/O pin connected to the left end of a key, the right end of the key is connected to the positive power supply, then we have to set the I/O pin for the pull-down mode, because this will make the key press down, can be pulled up the I/O pin. O pin to pull up, otherwise set the pull-up mode, that is, the function of the key is equal to the pendulum. Similarly, if the other end of the button is grounded, we have to set it to pull-up mode.
4. Summary
The purpose of the pull-up resistor is to ensure that the level of the input goes high when there is no signal input.
When the signal input is low, the level of the input should also be low. If there is no pull-up resistor, in the absence of external input, the input is suspended, its level is unknown and cannot be guaranteed, the pull-up resistor is to ensure that the input level is high when there is no signal input.
Pull-down resistor It is to ensure that the level of the input is low when there is no signal input.
In general, it is necessary to distinguish whether this GPIO port is used for input or output.