0% found this document useful (0 votes)
50 views12 pages

MicroControllerP1 3

The document discusses programming on ARM7 microcontrollers using the LPC2148. It provides instructions on setting up a Keil uVision project to write and build programs for the LPC2148. Example programs are given to perform arithmetic operations, find sums and factorials, and add arrays.

Uploaded by

Aman Singh
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)
50 views12 pages

MicroControllerP1 3

The document discusses programming on ARM7 microcontrollers using the LPC2148. It provides instructions on setting up a Keil uVision project to write and build programs for the LPC2148. Example programs are given to perform arithmetic operations, find sums and factorials, and add arrays.

Uploaded by

Aman Singh
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/ 12

AMC Engineering College, Bangalore

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.

BLOCK Diagram of ARMLPC2148

Dept of CSE-DS Microcontroller and Embedded System lab-21CS43 Page 8


AMC Engineering College, Bangalore

Step 1: After opening Keil uV4, Go to Project tab and click on close project

Then Create new uVision project

Now Select new folder and give name to Project.

Dept of CSE-DS Microcontroller and Embedded System lab-21CS43 Page 9


AMC Engineering College, Bangalore

Step 2: After Creating project now Select your device model. Example.NXP-LPC2148

[You can change it later from project window.]

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

Dept of CSE-DS Microcontroller and Embedded System lab-21CS43 Page 10


AMC Engineering College, Bangalore

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]

Now come on Project window.

Right click on target and click on options for target

Here you can change your device also.

Dept of CSE-DS Microcontroller and Embedded System lab-21CS43 Page 11


AMC Engineering College, Bangalore

Click output tab here & check create Hex file if you want to generate hex file

Now click on ok so it will save changes.

Step 7: Now Expand target and you will see source group

Right click on group and click on Add files to source group

Dept of CSE-DS Microcontroller and Embedded System lab-21CS43 Page 12


AMC Engineering College, Bangalore

Now add your program file which you have written in C/assembly.

You can see program file added under source group.

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.

Dept of CSE-DS Microcontroller and Embedded System lab-21CS43 Page 13


AMC Engineering College, Bangalore

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]

Dept of CSE-DS Microcontroller and Embedded System lab-21CS43 Page 14


AMC Engineering College, Bangalore

PROGRAMS

MODULE 1

Conduct the following experiments by writing program using ARM7TDMI/LPC2148


using anevaluation board/simulator and the required software tool.

Program 1:Write a program to Perform Arithmetic Operation.


AREA MULTIPLY, CODE, READONLY
ENTRY ; Mark first instruction to execute
START
MOV r1, #6400 ; STORE FIRST NUMBER INR0
MOV r2, #3200 ; STORE SECOND NUMBER INR1
MUL r3, r1, r2 ; MULTIPLICATION

END ; Mark end offile

Dept of CSE-DS Microcontroller and Embedded System lab-21CS43 Page 15


AMC Engineering College, Bangalore

MODULE 2

Program 2:Write a program to find the sum of first 10 integer numbers.


AREA SUM, CODE, READONLY

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

back Bback ; jumps back to C code

END

Dept of CSE-DS Microcontroller and Embedded System lab-21CS43 Page 16


AMC Engineering College, Bangalore

Program 3:Write a program to find factorial of a number.


AREA FACTORIAL, CODE, READONLY

ENTRY ; Mark first instruction to execute

START

MOVr0, #5 ; STORE FACTORIAL NUMBER INR0

MOV r1,r0 ; MOVE THE SAME NUMBER TOR1

FACT SUBS r1, r1,#1 ; SUBTRACTION

CMP r1,#1 ; COMPARISON

BEQSTOP

MULr3,r0,r1 ;MULTIPLICATION

MOVr0,r3 ;Result

BNEFACT ; BRANCH TO THE LOOP IF NOTEQUAL


STOP

END ;Mark end offile

Dept of CSE-DS Microcontroller and Embedded System lab-21CS43 Page 17


AMC Engineering College, Bangalore

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

ENTRY ; Mark first instruction to execute START


MOVR5,#6 ; INTIALISE COUNTER TO 6(i.e. N=6)
MOVR0,#0 ; INTIALISE SUM TOZERO
LDRR1,=VALUE1 ; LOADS THE ADDRESS OF FIRSTVALUE LOOP

LDRH R3,[R1],#02 ; READ 16 BIT DATA

ADD R0,R0,R3 ; ADD R0=R0+R3

SUBS R5,R5,#1 ; DECREMENT COUNTER

CMP R5,#0

BNE LOOP ; LOOK BACK TILL ARRAY ENDS

LDR R4,=RESULT ; LOADS THE ADDRESS OF RESULT

STR R0,[R4] ; STORES THE RESULT IN MEMORY

JMP B JMP

VALUE1DCW 0X1111, 0X2222, 0X3333, 0XAAAA, 0XBBBB,0XCCCC

; ARRAY OF 16 BIT NUMBERS (N=6)

AREADATA2,DATA,READWRITE ; TO STORE RESULT

RESULT DCD0X0
END ; Mark end offile

Dept of CSE-DS Microcontroller and Embedded System lab-21CS43 Page 18


AMC Engineering College, Bangalore

Dept of CSE-DS Microcontroller and Embedded System lab-21CS43 Page 19

You might also like