GPIO - General Purpose Input Output Module

General Purpose Input Output (GPIO)

  • Pins not selected for peripheral functions are general purpose input output (GPIO )port pins.
  • The ARM7 based LPC2148 Processor has 64 pins, it comes in Quad Flat Package.
  • There are two (2) ports in LPC2148 (PORT0 – 32 pins, PORT1- 32 pins)
  • PORT0 pins are designated as P0.0 to P0.31 while PORT1 pins are designated as P1.0 to P1.31.
  • There are in total 45 pins (P0.0 to P0.31, P1.16 to P1.31, except P0.24,P0.26, P0.27) that can be used as GPIO while rest 19 pins are used as Special Purpose pins.
  •  I/O port pins dynamically configured as input/output using GPIO registers. 

There are Two sets of GPIO modules present in LPC2148: Both control same I/O pins

  1. One set on APB, provides legacy (normal) GPIO functionality
  2. Another set on ARM local bus, provides enhanced FastGPIO function
    • In enhanced mode, registers are byte addressable
    • Includes mask registers to treat bits in groups

GPIO registers


  • IOxPIN – To get logic value on a I/O pin
  • IOxSET – To set an output configured pin (by writing 1 in corresponding bit)
  • IOxCLR - To clear an output configured pin (by writing 1 in corresponding bit)
  • IOxDIR – To select input /output function (by placing 0/1) for an I/O pin
    • (x = 0/1, i.e. Port-0 or Port-1)

Examples


Configuring & initializing GPIO pin:

PINSEL1=0x00000000;        // configure pins from P0.16 to P0.19 as GPIO
IO0DIR=0x000F0000;          // set pins P0.16 – P0.19 to output function
IO0SET=0x000F0000 ;        // set pins P0.16 & P0.18 of Port-0 HIGH
IO0CLR=0x000F0000 ;       // reset logic level of pin P0.16 of Port-0 LOW

Video Tutorial



References


  • WikiNote Foundation

Last modified: Monday, 23 March 2020, 9:16 PM