Вы находитесь на странице: 1из 3

LPC2148 Tutorials

E-Dazzling Technologies Page 1



Input & Output

LPC2148 has two I/O ports namely PORT0 and PORT1. Each PORT has 32 IO pins. In PORT0 pins
P0.24, P0.26 and P0.27 are not available. In PORT1 pins 0 to 15 are not available. Each Port Pin
has multiple functions. These functions can be selected by using Pin Connect Block. Pin Connect
Block contains three 32-bit registers namely PINSEL0, PINSEL1 and PINSEL2.

PINSEL 0 Register:
PINSEL0 register serves to select any function from the pins P0.0 to P0.15

Bit 31 30 29 28 27 26 25 24
Symbol P0.15 P0.14 P0.13 P0.12
Bit 23 22 21 20 19 18 17 16
Symbol P0.11 P0.10 P0.9 P0.8
Bit 15 14 13 12 11 10 9 8
Symbol P0.7 P0.6 P0.5 P0.4
Bit 7 6 5 4 3 2 1 0
Symbol P0.3 P0.2 P0.1 P0.0

PINSEL 1 Register:
PINSEL1 register serves to select any function from the pins P0.16 to P0.31

Bit 31 30 29 28 27 26 25 24
Symbol P0.31 P0.30 P0.29 P0.28
Bit 23 22 21 20 19 18 17 16
LPC2148 Tutorials

E-Dazzling Technologies Page 2

Symbol P0.27 P0.26 P0.25 P0.24
Bit 15 14 13 12 11 10 9 8
Symbol P0.23 P0.22 P0.21 P0.20
Bit 7 6 5 4 3 2 1 0
Symbol P0.19 P0.18 P0.17 P0.16

The PINSEL0 and PINSEL1 registers control the functions of device pins as shown below. Pairs of
bits in these registers correspond to specific device pins.

Value Function
00
Primary (default) function, typically GPIO
port
01 First alternate function
10 Second alternate function
11 Reserved

PINSEL2 Register:

Bit Symbol Function
0,1 - Reserved
2 GPIO/DEBUG
If 0 then, Pins P1.36-26 are used as
GPIO pins. If 1 then, Pins P1.36-26 are
used as a Debug port.
3 GPIO/TRACE
If 0 then, Pins P1.25-16 are used as
GPIO pins. If 1 then, Pins P1.25-16 are
used as a Trace port.
4 to 31 - Reserved


LPC2148 Tutorials

E-Dazzling Technologies Page 3

IOPIN (IO0PIN for PORT0 and IO1PIN for PORT1):
GPIO Port Pin value registers. The current state of the GPIO configured port pins can
always be read from this register, regardless of pin direction. This register has the current status
of the corresponding port.
IODIR (IO0DIR for PORT0 and IO1DIR for PORT1):
GPIO Port Direction control register. This register individually controls the direction of
each port pin. This register is used to set each port pin as either input or output. If 0, the port
pin is considered as input and if 1, then the port pin is considered as output.
IOSET (IO0SET for PORT0 and IO1SET for PORT1):
GPIO Port Output Set register. This register controls the state of output pins in
conjunction with the IOCLR register. Writing ones produces highs at the corresponding port
pins. Writing zeroes has no effect.
IOCLR (IO0CLR for PORT0 and IO1CLR for PORT1):
GPIO Port Output Clear registers. This register controls the state of output pins. Writing
ones produces lows at the corresponding port pins and clears the corresponding bits in the
IOSET register. Writing zeroes has no effect.

Вам также может понравиться