Jump to content

General-purpose input/output: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Monkbot (talk | contribs)
m Task 18 (cosmetic): eval 4 templates: del empty params (14×);
m Typo
 
(19 intermediate revisions by 16 users not shown)
Line 1: Line 1:
{{short description|User-controllable digital signal pin on an integrated circuit}}
{{short description|User-controllable digital signal pin on an integrated circuit}}
{{Use dmy dates|date=August 2013}}
{{Use dmy dates|date=June 2024}}


A '''general-purpose input/output''' ('''GPIO''') is an uncommitted digital signal pin on an [[integrated circuit]] or electronic circuit board which may be used as an input or output, or both, and is controllable by the user at [[Runtime (program lifecycle phase)|runtime]].
A '''general-purpose input/output''' ('''GPIO''') is an uncommitted digital signal [[Pin (electronics)|pin]] on an [[integrated circuit]] or electronic circuit (e.g. [[Microcontroller|MCUs]]/[[Microprocessor|MPUs]]) board which may be used as an input or output, or both, and is controllable by software.


GPIOs have no predefined purpose and are unused by default.<ref>{{Cite book |editor-last=White |editor-first=Jon |year=2016 |title=Raspberry Pi - The Complete Manual |publisher=[[Imagine Publishing]] |isbn=978-1785463709 |edition=7th |location=[[Bournemouth]], [[England]], [[United Kingdom]] |pages=36}}</ref><ref name=":0">{{Cite book |url=https://docs.oracle.com/javame/8.0/me-dev-guide/toc.htm |title=Oracle Java ME Embedded Developer's Guide |publisher=[[Oracle Corporation]]|year=2014|edition=8|chapter=General Purpose Input/Output|chapter-url=https://docs.oracle.com/javame/8.0/me-dev-guide/gpio.htm}}</ref> If used, the purpose and behavior of a GPIO is defined and implemented by the designer of higher assembly-level circuitry: the circuit board designer in the case of integrated circuit GPIOs, or system integrator in the case of board-level GPIOs.
GPIOs have no predefined purpose and are unused by default.<ref>{{Cite book |editor-last=White |editor-first=Jon |year=2016 |title=Raspberry Pi The Complete Manual |publisher=[[Imagine Publishing]] |isbn=978-1785463709 |edition=7th |location=[[Bournemouth]], [[England]], [[United Kingdom]] |pages=36}}</ref><ref name=":0">{{Cite book |url=https://docs.oracle.com/javame/8.0/me-dev-guide/toc.htm |title=Oracle Java ME Embedded Developer's Guide |publisher=[[Oracle Corporation]]|year=2014|edition=8|chapter=General Purpose Input/Output|chapter-url=https://docs.oracle.com/javame/8.0/me-dev-guide/gpio.htm}}</ref> If used, the purpose and behavior of a GPIO is defined and implemented by the designer of higher assembly-level circuitry: the circuit board designer in the case of integrated circuit GPIOs, or system integrator in the case of board-level GPIOs.


==Integrated circuit GPIOs==
==Integrated circuit GPIOs==

Integrated circuit (IC) GPIOs are implemented in a variety of ways. Some ICs provide GPIOs as a primary function whereas others include GPIOs as a convenient "accessory" to some other primary function. Examples of the former include the [[Intel 8255]], which interfaces 24 GPIOs to a [[parallel communication]] bus, and various GPIO ''expander'' ICs, which interface GPIOs to [[serial communication]] buses such as [[I²C]] and [[SMBus]]. An example of the latter is the [[Realtek]] ALC260 IC, which provides eight GPIOs along with its main function of [[audio codec]].
Integrated circuit (IC) GPIOs are implemented in a variety of ways. Some ICs provide GPIOs as a primary function whereas others include GPIOs as a convenient "accessory" to some other primary function. Examples of the former include the [[Intel 8255]], which interfaces 24 GPIOs to a [[parallel communication]] bus, and various GPIO ''expander'' ICs, which interface GPIOs to [[serial communication]] buses such as [[I²C]] and [[SMBus]]. An example of the latter is the [[Realtek]] ALC260 IC, which provides eight GPIOs along with its main function of [[audio codec]].


[[Microcontroller]] ICs usually include GPIOs. Depending on the application, a microcontroller's GPIOs may comprise its primary interface to external circuitry or they may be just one type of I/O used among several, such as [[analog signal]] I/O, counter/timer, and serial communication.
[[Microcontroller]] ICs usually include GPIOs. Depending on the application, a microcontroller's GPIOs may comprise its primary interface to external circuitry or they may be just one type of I/O used among several, such as [[analog signal]] I/O, counter/timer, and serial communication.


In some ICs, particularly microcontrollers, a GPIO pin may be capable of alternate functions. Often in such cases it is necessary to configure the pin to operate as a GPIO (vis-á-vis its alternate functions) in addition to configuring the GPIO's behavior. Some microcontroller devices (e.g., Microchip dsPIC33 family) incorporate internal signal routing circuitry that allows GPIOs to be programmatically mapped to device pins. [[Field-programmable gate array]]s (FPGA) extend this ability by allowing GPIO pin mapping, instantiation and architecture to be programmatically controlled.
In some ICs, particularly microcontrollers, a GPIO pin may be capable of other functions than GPIO. Often in such cases it is necessary to configure the pin to operate as a GPIO (vis-à-vis its other functions) in addition to configuring the GPIO's behavior. Some microcontroller devices (e.g., Microchip dsPIC33 family) incorporate internal signal routing circuitry that allows GPIOs to be programmatically mapped to device pins. [[Field-programmable gate array]]s (FPGA) extend this ability by allowing GPIO pin mapping, instantiation and architecture to be programmatically controlled.


<gallery>
<gallery>
File:Ic-photo-Intel--D8255.JPG|Parallel bus interface to 24 GPIOs (Intel 8255)
File:Ic-photo-Intel--D8255.JPG|Parallel bus interface to 24 GPIOs ([[Intel 8255]])
File:Rockwell R6522P Versatile Interface Adapter.jpg|A "versatile interface adapter", which combines 20 GPIOs with other general-purpose interfaces (MOS Technology 6522)
File:Rockwell R6522P Versatile Interface Adapter.jpg|A "versatile interface adapter", which combines 20 GPIOs with other general-purpose interfaces ([[MOS Technology 6522]])
File:PIC18F8720.jpg|A microcontroller with 29 remappable GPIOs (Microchip Technology PIC24FJ256)
File:PIC18F8720.jpg|A [[PIC microcontrollers|PIC microcontroller]] with 29 remappable GPIOs ([[Microchip Technology]] PIC24FJ256)
</gallery>
</gallery>


==Board-level GPIOs==
==Board-level GPIOs==

Many circuit boards expose board-level GPIOs to external circuitry through integrated electrical connectors. Usually, each such GPIO is accessible via a dedicated connector pin.
Many circuit boards expose board-level GPIOs to external circuitry through integrated electrical connectors. Usually, each such GPIO is accessible via a dedicated connector pin.


Like IC-based GPIOs, some boards merely include GPIOs as a convenient, auxiliary resource that augments the board's primary function, whereas in other boards the GPIOs are the central, primary function of the board. Some boards, which are classified usually as multi-function I/O boards, are a combination of both; such boards provide GPIOs along with other types of general-purpose I/O. GPIOs are also found on embedded controller boards such as [[Arduino]], [[BeagleBone]], and [[Raspberry Pi]].<ref>{{Cite web |url=https://www.raspberrypi.org/documentation/hardware/raspberrypi/gpio/README.md |title=GPIO - Raspberry Pi Documentation |website=Raspberry Pi Foundation |access-date=2016-11-03}}</ref>
Like IC-based GPIOs, some boards merely include GPIOs as a convenient, auxiliary resource that augments the board's primary function, whereas in other boards the GPIOs are the central, primary function of the board. Some boards, which are classified usually as multi-function I/O boards, are a combination of both; such boards provide GPIOs along with other types of general-purpose I/O. GPIOs are also found on embedded controller boards and [[Single board computer]]s such as [[Arduino]], [[BeagleBone]], and [[Raspberry Pi]].<ref>{{Cite web |url=https://www.raspberrypi.org/documentation/hardware/raspberrypi/gpio/README.md |title=GPIO Raspberry Pi Documentation |website=Raspberry Pi Foundation |access-date=2016-11-03}}</ref>


Board-level GPIOs are often given abilities which IC-based GPIOs usually lack. For example, [[schmitt-trigger]] inputs, high-current output drivers, [[optical isolator]]s, or combinations of these, may be used to buffer and condition the GPIO signals and to protect board circuitry. Also, higher-level functions are sometimes implemented, such as input [[debounce]], input [[signal edge]] detection, and [[pulse-width modulation]] (PWM) output.
Board-level GPIOs are often given abilities which IC-based GPIOs usually lack. For example, [[Schmitt-trigger]] inputs, high-current output drivers, [[optical isolator]]s, or combinations of these, may be used to buffer and condition the GPIO signals and to protect board circuitry. Also, higher-level functions are sometimes implemented, such as input [[debounce]], input [[signal edge]] detection, and [[pulse-width modulation]] (PWM) output.


<gallery>
<gallery>
File:BPI-R1-GPIO.jpg|Network router with three GPIOs (Banana Pi R1)
BPI-R1-GPIO.jpg|Network router with three GPIOs (Banana Pi R1)
File:HP 82940A GPIO Interface interior.jpg|GPIO interface for Hewlett-Packard Series 80 computers (HP 82940A)
HP 82940A GPIO Interface interior.jpg|GPIO interface for Hewlett-Packard Series 80 computers (HP 82940A)
File:48 GPIO Ethernet interface.jpg|Ethernet interface to 48 GPIOs (Sensoray 2410)
48 GPIO Ethernet interface.jpg|Ethernet interface to 48 GPIOs (Sensoray 2410)
Asus Tinker Board.jpg|Color coded GPIOs (top) on an [[Asus Tinker Board]]
</gallery>
</gallery>


Line 37: Line 36:
GPIOs are used in a diverse variety of applications, limited only by the electrical and timing specifications of the GPIO interface and the ability of software to interact with GPIOs in a sufficiently timely manner.
GPIOs are used in a diverse variety of applications, limited only by the electrical and timing specifications of the GPIO interface and the ability of software to interact with GPIOs in a sufficiently timely manner.


GPIOs usually employ standard logic levels and cannot supply significant current to output loads. When followed by an appropriate high-current output buffer (or mechanical or solid-state relay), a GPIO may be used to control high-power devices such as lights, solenoids, heaters, and motors (e.g., fans and blowers). Similarly, an input buffer, relay or opto-isolator is often used to translate an otherwise incompatible signal (e.g., high voltage) to the logic levels required by a GPIO.
GPIOs usually employ standard logic levels and cannot supply significant current to output loads. When followed by an appropriate high-current output [[Digital buffer|buffer]] (or mechanical or solid-state relay), a GPIO may be used to control high-power devices such as lights, solenoids, heaters, and motors (e.g., fans and blowers). Similarly, an input buffer, relay or opto-isolator is often used to translate an otherwise incompatible signal (e.g., high voltage) to the logic levels required by a GPIO.


Integrated circuit GPIOs are commonly used to control or monitor other circuitry (including other ICs) on a board. Examples of this include enabling and disabling the operation of (or power to) other circuitry, reading the states of on-board switches and configuration shunts, and driving [[light-emitting diode]] (LED) status indicators. In the latter case, a GPIO can, in many cases, supply enough output current to directly power an LED without using an intermediate buffer.
Integrated circuit GPIOs are commonly used to control or monitor other circuitry (including other ICs) on a board. Examples of this include enabling and disabling the operation of (or power to) other circuitry, reading the states of on-board switches and configuration shunts, and driving [[light-emitting diode]] (LED) status indicators. In the latter case, a GPIO can, in many cases, supply enough output current to directly power an LED without using an intermediate buffer.


Multiple GPIOs are sometimes used together as a [[bit banging]] communication interface. For example, two GPIOs may be used to implement a serial communication bus such as Inter-Integrated Circuit ([[I²C]]), and four GPIOs can be used to implement a [[Serial Peripheral Interface]] (SPI) bus; these are usually used to facilitate serial communication with ICs and other devices which have compatible serial interfaces, such as sensors (e.g., temperature sensors, pressure sensors, [[accelerometer]]s) and motor controllers. Taken to the extreme, this method may be used to implement an entire parallel bus, thus allowing communication with bus-oriented ICs or circuit boards.
Multiple GPIOs are sometimes used together as a [[bit banging]] communication interface. For example, two GPIOs may be used to implement a serial communication bus such as Inter-Integrated Circuit ([[I²C]]), and four GPIOs can be used to implement a [[Serial Peripheral Interface]] (SPI) bus; these are usually used to facilitate serial communication with ICs and other devices which have compatible serial interfaces, such as sensors (e.g., temperature sensors, pressure sensors, [[accelerometer]]s) and [[motor controller]]s. Taken to the extreme, this method may be used to implement an entire parallel bus, thus allowing communication with bus-oriented ICs or circuit boards.


Although GPIOs are fundamentally digital in nature, they are often used to control linear processes. For example, a GPIO may be used to control motor speed, light intensity, or temperature. Usually, this is done via PWM, in which the duty cycle of the GPIO output signal determines the effective magnitude of the process control signal. For example, when controlling light intensity, the light may be dimmed by reducing the GPIO duty cycle. Some linear processes require a linear control voltage. In such cases, it may be feasible to connect a GPIO, which is operated as a PWM output, to an RC filter to create a simple, low cost [[digital-to-analog converter]].
Although GPIOs are fundamentally digital in nature, they are often used to control analog processes. For example, a GPIO may be used to control motor speed, light intensity, or temperature. Usually, this is done via PWM, in which the duty cycle of the GPIO output signal determines the effective magnitude of the process control signal. For example, when controlling light intensity, the light may be dimmed by reducing the GPIO duty cycle. Some analog processes require an analog control voltage. In such cases, it may be feasible to connect a GPIO, which is operated as a PWM output, to an RC filter to create a simple, low cost [[digital-to-analog converter]].


==Implementation==
==Implementation==

GPIO interfaces vary widely. In some cases, they are simple—a group of pins that can switch as a group to either input or output. In others, each pin can be set up to accept or source different logic voltages, with configurable drive strengths and [[Pull-up resistor|pull ups/downs]]. Input and output voltages are usually, but not always, limited to the supply voltage of the device with the GPIOs, and may be damaged by greater voltages.
GPIO interfaces vary widely. In some cases, they are simple—a group of pins that can switch as a group to either input or output. In others, each pin can be set up to accept or source different logic voltages, with configurable drive strengths and [[Pull-up resistor|pull ups/downs]]. Input and output voltages are usually, but not always, limited to the supply voltage of the device with the GPIOs, and may be damaged by greater voltages.


A GPIO pin's state may be exposed to the software developer through one of a number of different interfaces, such as a [[memory-mapped I/O]] peripheral, or through dedicated IO port instructions. Some GPIOs have 5&nbsp;V tolerant inputs: even when the device has a low supply voltage (such as 2&nbsp;V), the device can accept 5&nbsp;V without damage.
A GPIO pin's state may be exposed to the software developer through one of a number of different interfaces, such as a [[memory-mapped I/O]] peripheral, or through dedicated IO port instructions. Some GPIOs have 5&nbsp;V tolerant inputs: even when the device has a low supply voltage (such as 2&nbsp;V), the device can accept 5&nbsp;V without damage.


A GPIO port is a group of GPIO pins (usually 8 GPIO pins) arranged in a group and controlled as a group.<ref name=":1" />
A GPIO port is a group of GPIO pins (often 8 pins, but it may be less) arranged in a group and controlled as a group.


GPIO abilities may include:<ref name=":0" />
GPIO abilities may include:<ref name=":0" />
* GPIO pins can be configured to be input or output
* GPIO pins can be configured to be input or output<ref name=":1">{{Cite book|url=http://www.egr.msu.edu/classes/ece480/capstone/fall09/group03/AN_balachandran.pdf|title=General Purpose Input/Output (GPIO)|last=Balachandran|first=Sasang|publisher=[[Michigan State University College of Engineering]]|year=2009}}</ref>
* GPIO pins can be enabled/disabled
* GPIO pins can be enabled/disabled
* Input values are readable (usually [[Binary number|high or low]])
* Input values are readable (usually [[Binary number|high or low]])
Line 69: Line 67:


== External links ==
== External links ==
* [https://wiki.freebsd.org/FreeBSD/GPIO GPIO framework for FreeBSD]
* [https://wiki.freebsd.org/FreeBSD/GPIO GPIO framework for FreeBSD] {{Webarchive|url=https://web.archive.org/web/20170905184124/https://wiki.freebsd.org/FreeBSD/GPIO |date=5 September 2017 }}
* [https://www.freebsd.org/cgi/man.cgi?gpio(3) FreeBSD gpio(3) API manual]
* [https://www.freebsd.org/cgi/man.cgi?gpio(3) FreeBSD gpio(3) API manual]
* [https://www.freebsd.org/cgi/man.cgi?gpioctl(8) FreeBSD gpioctl(8) manual]
* [https://www.freebsd.org/cgi/man.cgi?gpioctl(8) FreeBSD gpioctl(8) manual]

Latest revision as of 16:33, 23 August 2024

A general-purpose input/output (GPIO) is an uncommitted digital signal pin on an integrated circuit or electronic circuit (e.g. MCUs/MPUs) board which may be used as an input or output, or both, and is controllable by software.

GPIOs have no predefined purpose and are unused by default.[1][2] If used, the purpose and behavior of a GPIO is defined and implemented by the designer of higher assembly-level circuitry: the circuit board designer in the case of integrated circuit GPIOs, or system integrator in the case of board-level GPIOs.

Integrated circuit GPIOs

[edit]

Integrated circuit (IC) GPIOs are implemented in a variety of ways. Some ICs provide GPIOs as a primary function whereas others include GPIOs as a convenient "accessory" to some other primary function. Examples of the former include the Intel 8255, which interfaces 24 GPIOs to a parallel communication bus, and various GPIO expander ICs, which interface GPIOs to serial communication buses such as I²C and SMBus. An example of the latter is the Realtek ALC260 IC, which provides eight GPIOs along with its main function of audio codec.

Microcontroller ICs usually include GPIOs. Depending on the application, a microcontroller's GPIOs may comprise its primary interface to external circuitry or they may be just one type of I/O used among several, such as analog signal I/O, counter/timer, and serial communication.

In some ICs, particularly microcontrollers, a GPIO pin may be capable of other functions than GPIO. Often in such cases it is necessary to configure the pin to operate as a GPIO (vis-à-vis its other functions) in addition to configuring the GPIO's behavior. Some microcontroller devices (e.g., Microchip dsPIC33 family) incorporate internal signal routing circuitry that allows GPIOs to be programmatically mapped to device pins. Field-programmable gate arrays (FPGA) extend this ability by allowing GPIO pin mapping, instantiation and architecture to be programmatically controlled.

Board-level GPIOs

[edit]

Many circuit boards expose board-level GPIOs to external circuitry through integrated electrical connectors. Usually, each such GPIO is accessible via a dedicated connector pin.

Like IC-based GPIOs, some boards merely include GPIOs as a convenient, auxiliary resource that augments the board's primary function, whereas in other boards the GPIOs are the central, primary function of the board. Some boards, which are classified usually as multi-function I/O boards, are a combination of both; such boards provide GPIOs along with other types of general-purpose I/O. GPIOs are also found on embedded controller boards and Single board computers such as Arduino, BeagleBone, and Raspberry Pi.[3]

Board-level GPIOs are often given abilities which IC-based GPIOs usually lack. For example, Schmitt-trigger inputs, high-current output drivers, optical isolators, or combinations of these, may be used to buffer and condition the GPIO signals and to protect board circuitry. Also, higher-level functions are sometimes implemented, such as input debounce, input signal edge detection, and pulse-width modulation (PWM) output.

Usage

[edit]

GPIOs are used in a diverse variety of applications, limited only by the electrical and timing specifications of the GPIO interface and the ability of software to interact with GPIOs in a sufficiently timely manner.

GPIOs usually employ standard logic levels and cannot supply significant current to output loads. When followed by an appropriate high-current output buffer (or mechanical or solid-state relay), a GPIO may be used to control high-power devices such as lights, solenoids, heaters, and motors (e.g., fans and blowers). Similarly, an input buffer, relay or opto-isolator is often used to translate an otherwise incompatible signal (e.g., high voltage) to the logic levels required by a GPIO.

Integrated circuit GPIOs are commonly used to control or monitor other circuitry (including other ICs) on a board. Examples of this include enabling and disabling the operation of (or power to) other circuitry, reading the states of on-board switches and configuration shunts, and driving light-emitting diode (LED) status indicators. In the latter case, a GPIO can, in many cases, supply enough output current to directly power an LED without using an intermediate buffer.

Multiple GPIOs are sometimes used together as a bit banging communication interface. For example, two GPIOs may be used to implement a serial communication bus such as Inter-Integrated Circuit (I²C), and four GPIOs can be used to implement a Serial Peripheral Interface (SPI) bus; these are usually used to facilitate serial communication with ICs and other devices which have compatible serial interfaces, such as sensors (e.g., temperature sensors, pressure sensors, accelerometers) and motor controllers. Taken to the extreme, this method may be used to implement an entire parallel bus, thus allowing communication with bus-oriented ICs or circuit boards.

Although GPIOs are fundamentally digital in nature, they are often used to control analog processes. For example, a GPIO may be used to control motor speed, light intensity, or temperature. Usually, this is done via PWM, in which the duty cycle of the GPIO output signal determines the effective magnitude of the process control signal. For example, when controlling light intensity, the light may be dimmed by reducing the GPIO duty cycle. Some analog processes require an analog control voltage. In such cases, it may be feasible to connect a GPIO, which is operated as a PWM output, to an RC filter to create a simple, low cost digital-to-analog converter.

Implementation

[edit]

GPIO interfaces vary widely. In some cases, they are simple—a group of pins that can switch as a group to either input or output. In others, each pin can be set up to accept or source different logic voltages, with configurable drive strengths and pull ups/downs. Input and output voltages are usually, but not always, limited to the supply voltage of the device with the GPIOs, and may be damaged by greater voltages.

A GPIO pin's state may be exposed to the software developer through one of a number of different interfaces, such as a memory-mapped I/O peripheral, or through dedicated IO port instructions. Some GPIOs have 5 V tolerant inputs: even when the device has a low supply voltage (such as 2 V), the device can accept 5 V without damage.

A GPIO port is a group of GPIO pins (often 8 pins, but it may be less) arranged in a group and controlled as a group.

GPIO abilities may include:[2]

  • GPIO pins can be configured to be input or output
  • GPIO pins can be enabled/disabled
  • Input values are readable (usually high or low)
  • Output values are writable/readable
  • Input values can often be used as IRQs (usually for wakeup events)

See also

[edit]

References

[edit]
  1. ^ White, Jon, ed. (2016). Raspberry Pi – The Complete Manual (7th ed.). Bournemouth, England, United Kingdom: Imagine Publishing. p. 36. ISBN 978-1785463709.
  2. ^ a b "General Purpose Input/Output". Oracle Java ME Embedded Developer's Guide (8 ed.). Oracle Corporation. 2014.
  3. ^ "GPIO – Raspberry Pi Documentation". Raspberry Pi Foundation. Retrieved 3 November 2016.
[edit]