Anda di halaman 1dari 12

ARM LPC2148

Introduction
• ARM7TDMI-S
• 32-bit RISC Microcontroller with Thumb extensions
• 512KB on-chip Flash ROM
• 32KB RAM
• Vectored Interrupt Controller
• Two UARTs
Pins
• 64 pins – 48 are used
• 64 – Two ports – P0 and P1 of 32 pins each
• Each port is further grouped to two, 16 pins each
• P1 pins 0-15 not used
Registers for Programming
• PINSELX
• IOXPIN
• IOXDIR
• IOXSET
• IOXCLR
Registers for Programming - PINSELX
• 32-bit register.
• X and pins
X Port Pins
0 0 0-15
1 0 16-31
2 1 16-31

• For eg. Consider PINSEL0


• 32-bit register for 16 pins  2bits per pin  Default 00(GPIO)

31 1 0
PINSEL0 functionalities
Registers for Programming - IOXPIN
• 32 bit register
• To read or write values directly to a pin
• 32 bits for 32 pins  1 bit/pin
• 0  Input; 1 Output
Registers for Programming - IOXDIR
• 32 bit register
• To set direction of port X (0 or 1)
• 32 bits for 32 pins  1 bit/pin
• 0  Input; 1 Output
Registers for Programming – IOXSET and IOXCLR
• 32 bit registers to set or clear IO port

• When a bit in the IOSET register is set to ‘1’, the corresponding pin is set to
Logic 1. Setting a bit ‘0’ in this register has no effect on the pin. It is used to
set the value of a GPIO pin that is configured as output to High (Logic 1).

• When a bit in the IOCLR register is set to ‘1’, the corresponding pin in the
respective Port is set to Logic 0 and at the same time clears the
corresponding bit in the IOSET register. Setting ‘0’ in the IOCLR has no
effect on the pin. It is used to set the value of a GPIO pin that is configured
as output to Low (Logic 0).
Pins used in programming
Component Port Pins ON OFF
LED P1 16, 17, 18, 19 Set these pins to 1
Buzzer P0 11 Set as 0 1
Buttons
A simple Program
#include <lpc214x.h>
int delay;
int main (void)
{
PINSEL2 = 0x00000000;
IO1DIR = 0xFFFFFFFF; // All the pins of PORT1 are configured as Output
while (1)
{
IO1SET = 0xFFFFFFFF; // Set Logic 1 to all the PORT1 pins i.e. turn on LEDs
for (delay = 0; delay<500000; delay++)
IO1CLR = 0xFFFFFFFF; // Set Logic 0 to all the PORT1 pins i.e. turn off LEDs
for (delay = 0; delay<500000; delay++)
}
return 0;
}
Steps to do programming in Keil

Anda mungkin juga menyukai