Lesson 09: GPIO Ports and Configurations

The microprocessors access their I/O (Input/Output) devices either via special I/O instructions that read and write to peripherals located in a separate I/O address space, called "Port Mapped I/O, PMIO", or via instructions that access memory, called "Memory-mapped I/O, MMIO". ARM-based processors use memory-mapped I/O. The I/O ports share the same address space as memory. That means the software can access an I/O port simply by reading from or writing to the appropriate address, and these addresses are usually called "Registers". Most I/O ports can be configured for different I/O functions via registers; you can find detailed information about I/O registers in the microprocessor's datasheet.

Even though the accessing I/O register looks like reads and writes to memory variables, there are still some differences between the memory and I/O Registers. For example, some bits in the Register are read-only, and some are write-only; some bits can only be cleared or set; some bits cannot be modified, and some are reserved for future use.


General-Purpose Input/Output (GPIO)

A GPIO is a generic pin on a microcontroller that can be controlled by the program at runtime. GPIO pins have no predefined purpose and can be operated as parallel interfaces. It allows the microcontroller to exchange digital information with external devices. For example, GPIO can be used to read from a temperature sensor and to write to an LCD module or LEDs for status.

GPIO pins have the following capabilities:

  1. GPIO pins can be configured to be input or output
  2. GPIO pins can be enabled or disabled
  3. Input values are readable( typically logic high or low)
  4. Output values are writable and can be read back
  5. The input pin can be used to trigger the interrupt function

Instead of directly configuring and controlling each individual GPIO pin, we set up a group of GPIO pins (typically 8 GPIO pins) into a PORT. Through the PORT registers, we can simultaneously control and access multiple GPIO pins.

© 2026 Air Supply Information Center (Air Supply BBS)