GPIO Stands for General
Purpose Input and Output pins in microcontroller. Peripherals in
microcontrollers such as UART, ADC, SPI, DAC etc. will interact with the
external environment through GPIO pins. To communicate with external
environments core uses GPIO pins. For example to transmit or receive data from
devices core will manages TX and RX pins for that purpose. Depending on
the operation required GPIO pins can be configured in PUT or OUT put mode. For
example if controller giving any command to external environment GPIO pin will
be in OUT put mode and if controller getting data for manipulation GPIO pin
will be in INPUT mode.
In microcontroller there
are different modes for INPUT and OUT put. These mode can be selected through
peripheral registers in microcontroller.
GPIO
Input Mode
GPIO input mode can be
selected by writing GPIO data direction and control registers. GPIO input mode
is of following types:
High
Impedance Mode
This mode is also called
Tri-State or Floating point mode. In this mode pin status is not deterministic
until external source is applied. By Default controllers pins are in floating
point mode. Advantage of using High Impedance State is that controller pin can
be pulled to high or low with less current. It is used in ADC sense when it
required keeping ADC sense signal to be low.
Pull
Up/Pull down Mode
In Pull up mode
controllers pin will remain high until it is forced to ground by external
source. In this mode a week pull up resistor is connected to VDD (controller
supply) internal to pin microcontroller. In pull down mode controllers pin
remains low until external supply is not applied. In this mode a week pull down
resistor to ground. Pull up and pull down is used to ensure a defined state of
input pin. This mode is used for external interrupt pins, ADC etc.
All GPIO input pins uses the concept of hysteresis to prevent spurious changes in state when an input value changes. Hysteresis is implemented on GPIO by setting two thresholds for a digital input which are VIH and VIL typically enumerated in the “Electrical Characteristics” section of microcontroller datasheets. VIH is the input-high voltage and represents the minimum voltage that must be applied to drive the pin high. VIL is the maximum input-low voltage needed to drive the pin low. This means if the input voltage is greater than VIL and less than VIH, the value at the pin depends on whether the past input value was above VIH, in which case the pin is high, or below VIL, which means the pin is low.
GPIO OUT MODE
GPIO input mode can be selected by writing GPIO
data direction and control registers. In Microcontroller output mode is of
following types:
PUSH –PULL MODE
Push-Pull Output Configuration uses two Mosfet
or transistors. One is N-Channel and another is P-Channel Mosfet. The Upper
switch will be ON when the output has to be driven high. It will connect
controller pin directly with VDD. Lower switch will be ON when output has to be
driven LOW. In this mode Pin State is deterministic. It will have any one state
either High or Low Push Pull configuration will have the capability to Source or
Sink the Current.
OPEN DRAIN MODE
In this mode, the physical GPIO pin
behaves same way as drain of MOSFET. The drain is open to connect it to any
external element. The source is grounded and gate of internally driven. It has
two states: either High-impedance or Low. The output pin is driven low by
firmware, the voltage at pin is zero. When the output pin is driven high by
firmware, the voltage can be either high or low
. It is mostly used for I2C bus where
external pull-up resisters are used widely. It can be also used in Interrupt
line where it is connected to multiple interrupt sources.
No comments:
Post a Comment