MicroControllerP1 3
MicroControllerP1 3
Introduction to ARM7
The LPC2141/42/44/46/48 microcontrollers are based on a 16-bit/32-bit ARM7TDMI-S CPU with real-
time emulation and embedded trace support, that combine microcontroller with embedded high speed
flash memory ranging from 32 kB to 512 kB. A 128-bit wide memory interface and unique accelerator
architecture enable 32-bit code execution at the maximum clock rate. For critical code size applications,
the alternative 16-bit Thumb mode reduces code by more than 30 % with minimal performance penalty.
Due to their tiny size and low power consumption, LPC2141/42/44/46/48 are ideal for applications where
miniaturization is a key requirement, such as access control and point-of sale. Serial communications
interfaces ranging from a USB 2.0 Full-speed device, multiple UARTs, SPI, SSP to I2C-bus and on-chip
SRAM of 8 kB up to 40 kB, make these devices very well suited for communication gateways and
protocol converters, soft modems, voice recognition and low end imaging, providing both large buffer
size and high processing power. Various 32-bit timers, single or dual 10-bit ADC(s), 10-bit DAC, PWM
channels and 45 fast GPIO lines with up to nine edge or level sensitive external interrupt pins make these
microcontrollers suitable for industrial control and medical systems.
Step 1: After opening Keil uV4, Go to Project tab and click on close project
Step 2: After Creating project now Select your device model. Example.NXP-LPC2148
Step 3: so now your project is created and Message window will appear to add start up file of your
Device click on Yes so it will be added to your project folder
Step 4: Now go to File and create new file and save it with .C extension if you will write program in C
language or save with .asm for assembly language.
Step 5: Now write your program and save it again. You can try example given at end of this tutorial.
Step 6: After that on left you see project window [if it’s not there….go to View tab and click on project
window]
Click output tab here & check create Hex file if you want to generate hex file
Step 7: Now Expand target and you will see source group
Now add your program file which you have written in C/assembly.
Step 8: Now Click on Build target.You can find it under Project tab or in toolbar.It can also be done by
pressing F7 key.
Step 9: you can see Status of your program in Build output window
[If it’s not there go to view and click on Build output window]
PROGRAMS
MODULE 1
MODULE 2
ENTRY
MOVR1, #10 ; load 10 toregister
MOVR2, #0 ; empty the register to storeresult
loop
ADDR2, R2, R1 ; add the content of R1 with result at R2
SUBSR1, #0x01 ; Decrement R1 by 1
BNEloop ; repeat till r1 goes0
END
START
BEQSTOP
MULr3,r0,r1 ;MULTIPLICATION
MOVr0,r3 ;Result
Program 4:Write a program to add an array of 16 bit numbers and store the 32 bit
result in internal RAM.
AREA ADDITION, CODE, READONLY
CMP R5,#0
JMP B JMP
RESULT DCD0X0
END ; Mark end offile