How to Start Programming for ARM7 Based LPC2148 Microcontroller
How to Start Programming for ARM7 Based LPC2148 Microcontroller
[nextpage title=”Description” ]This article is about how to start programming for LPC 2148 micro-controller. For the new reader, it is more important to have basic knowledge of pin configuration, memory, I/O ports and basic registers. Here is the pin diagram of LPC 2148.
The first step towards programming is HOW TO CONFIGURE GPIO Pins. Let’s start with the associated concepts and registers.
Total of 30 input/output and asingle output only pin out of 32 pins are available on PORT0. PORT1 has up to 16 pinsavailable for GPIO functions. PORT0 and PORT1 are controlled via two groups of registers explained below.
Port 0 has 32 pins (P0.0 to P0.31). Each pin can have multiple functions. On RESET, all pins are configured as GPIO pins. However we can re-configure using the registers IOSEL0 and IOSEL1.
IOSEL0 is used to select function of P0.0 to P0.15. Each pin has up to 4 functions so 2 bits/pin in IOSEL0 is provided for selecting function.
2.IOSEL1
IOSEL1 is used to select function of pins P0.16 to P0.31
3.IOSEL2
IOSEL2 is used to select function of pins P1.16 to P1.31
4.IO0DIR
IO0DIR is used to configure pins of port 0-P0 as input or output pins.
1= output pin
0= input pin
Example: IO0DIR=0x0000ffff means P0.0 to P0.15 are configured as output pins and P0.16 to P0.31 are configured as input pins.
5.IO1DIR
IO1DIR is used to configure pins of port 1-P1 as input or output pins.
1= output pin
0= input pin
Example: IO0DIR=0xaaaaaaaa means even pins (P1.0, P1.2, P1.4 etc.) are configured as input pins and odd pins (P1.1, P1.3, P1.5 etc.) are configured as input pins.
6. IO0SET
It is used to set pins of Port0-P0 to logic 1.
Example: IO0SET=0x0000ffff will set pins P0.0 to P0.15 at logic 1. It will not affect other pins.
7. IO0CLR
It is used to set pins of Port0-P0 to logic 0.
Example: IO0SET=0x0000ffff will set pins P0.0 to P0.15 at logic 0. It will not affect other pins.
8. IO1SET
It is used to set pins of Port1-P1 to logic 1.
Example: IO1SET=0x0000ffff will set pins P1.0 to P1.15 at logic 1. It will not affect other pins.
9.IO1CLR
It is used to set pins of Port1-P1 to logic 0.
Example: IO1SET=0x0000ffff will set pins P1.0 to P1.15 at logic 0. It will not affect other pins.
Once the use of above all registers is perfectly understood, you are good to go with programming.
Example: Blink LEDs connected on pins P1.16-P1.23
Step-1: Specify the direction of pins as output using IO1DIR.
Step-2:Set pins P1.16-P1.23 using IO1SET.
Step-3:Clear pins P1.16-P1.23 using IO1CLR.
Step-4:Go to step-2.
Post Comment
You must be logged in to post a comment.