Digital Input Output / General Purpose Input Output ports in Microcontroller, LPC11C24
4 GPIO ports are there MCU on-chip
GPIO0
GPIO1
GPIO2
GPIO3
There are 2 registers available for each of the GPIO ports.
Port IO direction register (DIR)
o To configure the IO direction, we have to program the bit-positions in this register
o To configure any pin as input, the relevant bit-position to be reset (Write 0)
o To configure any pin as output, the relevant bit-position to be set (Write 1)
Port IO data read/ write Register (DATA)
o To make any IO pin to HIGH state, the relevant bit-position to be set (Write 1)
o To make any IO pin to LOW state, the relevant bit-position to be reset (Write 0)
o To know the current state of any IO pin, read the current state in relevant bit-position (Get Bit)
IO Port IO Direction Register IO Data Register
GPIO0 GPIO0_DIR GPIO0_DATA
GPIO1 GPIO1_DIR GPIO1_DATA
GPIO2 GPIO2_DIR GPIO2_DATA
GPIO3 GPIO3_DIR GPIO3_DATA
To operate the LED in software,
Configure the IO direction of GPIO1 pin#2 to OUTPUT
GPIO1_DIR |= (1<<2);
To glow the LED
GPIO1_DATA |= (1<<2);
To glow off the LED
GPIO1_DATA &= ~(1<<2);
To operate the LED in software,
Configure the IO direction of GPIO1 pin#2 to OUTPUT
GPIO1_DIR |= (1<<2);
To glow the LED
GPIO1_DATA &= ~(1<<2);
To glow off the LED
GPIO1_DATA |= (1<<2);