{{Short description|Peripheral device for bit-banging}} {{Distinguish|Programmed input–output}} In embedded systems and other computers, a '''programmable input/output''' ('''programmable IO''', '''PIO''') is a piece of hardware that manages input/output pins (such as GPIO) without requiring the constant attention of the CPU – essentially one that performs bit-banging in place of the CPU. Its behavior is determined by a program uploaded to the PIO chip by the CPU. It communicates with the CPU using interrupts.

== Embedded systems ==

Some microcontrollers include a PIO module to improve I/O performance. Two classic examples of embedded PIO include the PIO of Raspberry Pi Pico (RP2040; 2021)<ref name=pi-ser>{{Cite web |date=2023-01-24 |title=Raspberry Pi Pico Serial Communication Example(MicroPython) |url=https://electrocredible.com/raspberry-pi-pico-serial-uart-micropython/ |archive-url=https://web.archive.org/web/20230603201653/https://electrocredible.com/raspberry-pi-pico-serial-uart-micropython/ |archive-date=2023-06-03 |access-date=2023-06-10 |website=Electrocredible |language=en-US}}</ref> and the FlexIO from NXP (KL43; 2010s).<ref name=NXP_UART>{{Cite web |last=Krenek |first=Pavel |date=2015 |title=Emulating UART by Using FlexIO |url=https://www.nxp.com/docs/en/application-note/AN5034.pdf |url-status=live |archive-url=https://web.archive.org/web/20221005225314/http://www.nxp.com/docs/en/application-note/AN5034.pdf |archive-date=2022-10-05 |access-date=2023-06-10 |website=NXP}}</ref>

Much has been written about the PIO module of the RP2040 because of its low cost and educational focus. The RP2040 has two PIO modules, each of which has four hardware state machines, a RX FIFO, a TX FIFO, and a pair of shift registers. These state machines are programmed using a special assembly language<ref name=pi-ser/> (or equivalently, a syntactical transliteration from MicroPython).<ref>{{cite web |title=Programmable IO — MicroPython latest documentation |url=https://docs.micropython.org/en/latest/rp2/tutorial/pio.html |website=docs.micropython.org}}</ref> The PIO modules can access GPIO pins (only digitally), set/unset IRQ, and perform direct memory access. PIO can be used for UART serial communication,<ref name=pi-ser/> MIDI,<ref>{{Cite web |last=McKinney |first=Josh |date=2022-11-05 |title=Programmable IO (PIO) for MIDI with the Rasberry Pi Pico |url=https://www.joshka.net/2022/11/pio-for-midi-with-raspberry-pi-pico |url-status=live |archive-url=https://web.archive.org/web/20230404125731/https://www.joshka.net/2022/11/pio-for-midi-with-raspberry-pi-pico |archive-date=2023-04-04 |access-date=2023-06-10 |website=joshka.net}}</ref> and even send-only 10BASE-T and 100BASE-T ethernet.<ref>{{cite web |last1=Markgraf |first1=Steve |title=steve-m/Pico-100BASE-TX: Bit-banged 100 MBit/s Fast Ethernet transmitter and UDP framer for Raspberry Pi RP2040/RP2350 |url=https://github.com/steve-m/Pico-100BASE-TX |date=2 April 2026}}</ref>

The FlexIO from NXP predates the RP2040 PIO. It consists of 4 32-bit shifters, 4 16-bit timers, 8 bidirectional digital I/O pins, a number of configuration registers for each shifter and timer, and multiplexers for the input, timer, and output. It is programmed by setting the configuration registers so that the components chain together into the desired behavior.<ref>{{cite web |title=Understanding FlexIO |url=https://community.nxp.com/t5/Kinetis-Microcontrollers/Understanding-FlexIO/ta-p/1115419 |website=NXP Community |language=en |date=16 June 2015}}</ref> Official documentation is available for emulating UART, SPI, I2C, and I2S.<ref name=NXP_UART/>

== Industrial systems ==

Industrial programmable I/O controllers are available, but they generally represent more complex systems than an embedded PIO. They commonly capable of analog I/O, RS-232, and RS-485. For example: * A EN 50155 PIO designed for railcar use contains its own CPU, an NXP Vybrid VF50N.<ref>{{cite web |title=PC2610 - PC2 Configurable I/O Controller |url=https://www.duagon.com/products/control/i/o-controllers/details/pc2610 |website=www.duagon.com |language=en}}</ref> * An industrial "remote IO module" contains an Atmel SAM4E16E (Cortex-M4). It provides Ethernet access.<ref>{{cite web |title=Programmable I/O Controller Module |url=https://www.ien.eu/article/programmable-i-o-controller-module-1/ |website=IEN.EU - Industrial Engineering News Europe |language=en}}</ref> * A IEC 61131-3 PIO is described as functioning as a "local microcontroller".<ref>{{cite web |title=MX programmable IO modules - MX |url=https://www.leroy-automation.com/en/product/mx-2/ |website=Leroy Automation}}</ref>

== FPGA ==

There are dedicated PIO modules to be used with FPGA chips. These modules contain their own FPGA chip so they can perform the task in place of the main module.<ref>{{cite web |title=Simulink® Programmable I/O modules {{!}} Speedgoat |url=https://www.speedgoat.com/products-services/i-o-connectivity/simulink-programmable-fpga-i-o |website=www.speedgoat.com}}</ref>

== See also == * Freescale 683XX, which has a Timing Processor Unit (TPU)

== References == {{reflist}}

== External links == * [https://rp2040pio-docs.readthedocs.io/en/latest/ RP2040 PIO Emulator]

Category:Computer buses Category:Integrated circuits Category:Computer engineering Category:Industrial computing