There is something which i dont understand about values of pins.
If you insert the value 1 to a pin does it mean that you open the circuit of the pin (no current), and if you insert the value 0 to a pin you close the circuit?
By saying the 'circuit of the pin' i mean the circuit that contain the '1-logic' voltage source, a Pull-up/Pull-down resistor, and ground.
For example, if there is a GPIO pin P0_0 that is connected to a pull-up resistor, and configured as output, then P0_0=1 means that the pin's output is 1, and P0_0 = 0 means that the pin's output is 0?
and If its connected to pull-down resistor then P0_0 = 1 means that the pin's output is 0?
Most micro controllers output pins use a 'totem pole' output structure and can both source current when high and sink current when low, look at the devices data sheet to find out how much current they can source or sink, 25ma is a common amount.
If an output pin is 'open collector, or open drain' variety then it can only sink current and a external pull-up resistor is required to establish the High level voltage and set the source current level.
Most micro controllers output pins use a 'totem pole' output structure and can both source current when high and sink current when low, look at the devices data sheet to find out how much current they can source or sink, 25ma is a common amount.
If an output pin is 'open collector, or open drain' variety then it can only sink current and a external pull-up resistor is required to establish the High level voltage and set the source current level.
I dont understand how is the current issue answers my question.
my question is: is inserting a value 0 to a pin, opens the pin's circuit or closes the pin's circuit?
I dont understand how is the current issue answers my question.
my question is: is inserting a value 0 to a pin, opens the pin's circuit or closes the pin's circuit?
I dont understand how is the current issue answers my question.
my question is: is inserting a value 0 to a pin, opens the pin's circuit or closes the pin's circuit?
inserting a 0 closes a circuit to ground, 0vdc AND opens a circuit path to Vcc, +5vdc.
Inserting a 1 closes a circuit to +Vcc, 5vdc AND opens a circuit path to ground, 0vdc. There is a active circuit path always on for both a 1 and a 0 output state.
Sinking and sourcing current is very different from the pin being configured as an i/p, input detects the voltage on the pin for which we use pull up and pull down resistors(except in the case of open drain output where a pull up is required). The IC sinks current when it is at a lower voltage then the other end of that pin and sources it when it is connected to a lower voltage.
You have to understand the use of pullup/pulldown more to understand how this works
meaning :
If you have a pin with a external pull-down resistor. And the pin is a output pin. when you set it to a 0 its a 0 when you set it to a 1. Its still a 1. The reason for the resistor being there is so that it can switch faster to ground (0) and also if you use multiple devices like on SPI/I2C pins.
Many devices use those 2/3 lines. SDO, SDA, SCL. So if you have pullups the you can just set the pin to input this way another device can bring the line low. If not you may create a short somewhere because your micro will be send 5v and another device is sending 0v(gnd) on the same line.
So if you have a pullup and set the pin to output and place a 0 there it will indeed change to 0v
and if you have a pulldown and set the pin to output and send a 1 it will be 5v there.