0% found this document useful (0 votes)
1 views1 page

GPIO Programming

The LPC11C24 microcontroller features four GPIO ports (GPIO0, GPIO1, GPIO2, GPIO3) with two registers for each port: the IO direction register (DIR) and the IO data register (DATA). The DIR register configures pin direction (input/output), while the DATA register controls the pin state (HIGH/LOW) and reads the current state. The document provides examples of how to configure GPIO1 pin#2 to control an LED by setting the appropriate bits in the DIR and DATA registers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views1 page

GPIO Programming

The LPC11C24 microcontroller features four GPIO ports (GPIO0, GPIO1, GPIO2, GPIO3) with two registers for each port: the IO direction register (DIR) and the IO data register (DATA). The DIR register configures pin direction (input/output), while the DATA register controls the pin state (HIGH/LOW) and reads the current state. The document provides examples of how to configure GPIO1 pin#2 to control an LED by setting the appropriate bits in the DIR and DATA registers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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);

You might also like