Microcontroller Lab Manual-Usha
Microcontroller Lab Manual-Usha
Vision
To provide a quality and holistic education in data science, data analytics, data visualization,
industry collaborations and research for empowering individuals to derive knowledge, thereby
transform the potentials in data for the betterment of society.
Mission
1. Educate and prepare students with a strong foundation in data science, equipping them
with the skills, knowledge, and ethical principles needed to excel in data-driven fields.
2. Foster collaborations with industries to adopt modern data science and visualization
tools which solves the real-world problems that have societal benefits.
3. Cultivate a culture of life-long learning with intellectual curiosity in data science and
nurturing individuals who are passionate about data-driven decision-making.
Laboratory Outcomes: The student should be able to:
1. Explain the ARM Architectural features and Instructions.
2. Develop programs using ARM instruction set for an ARM Microcontroller.
3. Explain C-Compiler Optimizations and portability issues in ARM Microcontroller.
4. Apply the concepts of Exceptions and Interrupt handling mechanisms in developing
applications.
5. Demonstrate the role of Cache management and Firmware in Microcontrollers.
12. Life-long learning: Recognize the need for, and have the preparation
and ability to engage in independent and life-long learning in the broadest
context of technological change.
EXPERIMENTS
Module – 1
1.Using Keil software, observe the various Registers, Dump, CPSR, with a simple Assembly
Language Programs (ALP).
Module – 2
2. Develop and simulate ARM ALP for Data Transfer, Arithmetic and Logical operations
(Demonstrate with the help of a suitable program).
3. Develop an ALP to multiply two 16-bit binary numbers.
4. Develop an ALP to find the sum of first 10 integer numbers.
5. Develop an ALP to find the largest/smallest number in an array of 32 numbers.
6. Develop an ALP to count the number of ones and zeros in two consecutive memory
locations.
Module – 3
7. Simulate a program in C for ARM microcontroller using KEIL to sort the numbers in
ascending/descending order using bubble sort.
8. Simulate a program in C for ARM microcontroller to find factorial of a number
9. Simulate a program in C for ARM microcontroller to demonstrate case conversion of
characters from upper to lowercase and lower to uppercase.
Module – 4 and 5
10. Demonstrate enabling and disabling of Interrupts in ARM.
11. Demonstrate the handling of divide by zero, Invalid Operation and Overflow exceptions
in ARM.
INTRODUCTION
The µVision IDE combines project management, run-time environment, build
facilities, source code editing, and program debugging in a single powerful
environment. µVision is easy-to-use and accelerates your embedded software
development. µVision supports multiple screens and allows you to create individual
window layouts anywhere on the visual surface.
The µVision Debugger provides a single environment in which you may test, verify,
and optimize your application code. The debugger includes traditional features like
simple and complex breakpoints, watch windows, and execution control and provides
full visibility to device peripherals.
LPC2148 Microcontroller
STEPS TO BE FOLLOWED
Step6: After selecting LPC2148 a dialogue window is opened as shown in the snapshot.
Select -
Step12: Now go to Source Group1 – right click – select - Add Existing files to Group
‘Source Group1’ as shown
Step13: A dialogue box opens from that select the file abc.s and click Add as shown
Step15: To compile the program click on the file abc.s – right click- select Build target
as shown
Step16: After compilation Build output is displayed wrt errors and warning as shown
Step18: Select OK
Step19: OUTPUT
EXPERIMENT – 1
Using Keil software, observe the various Registers, Dump, CPSR (Current Program
Status Register), with a simple Assembly Language Programs (ALP).
OUTPUT
EXPERIMENT – 2
Develop and simulate ARM ALP for Data Transfer, Arithmetic and Logical operations
(Demonstrate with the help of a suitable program).
AREA PRG2, CODE, READONLY; defining logical area named prg2 and the code
ENTRY; the entry point where the code starts
LDR R0, =5; data transfer – R0=5
LDR R1, =3; R1=3
ADD R2, R0, R1; arithmetic ADD R2=8 (5+3)
SUB R3, R0, R1; SUB R3=2 (5-3)
MUL R4, R0, R1; MUL R4=F (5*3 = 15 = F)
AND R5, R0, R1; logical AND R5=1 (5&&3)
ORR R6, R0, R1 ; OR R6=7 (5||3)
EOR R7,R0,R1; XOR R7=6 (5^3)
END; end of the program
OUTPUT
EXPERIMENT – 3
Develop an ALP to multiply two 16-bit binary numbers.
AREA MULTIPY,CODE,READONLY
ENTRY
MOV R1,#0002
MOV R2,#0004
MUL R3,R1,R2
REPEAT B REPEAT
END
OUTPUT
EXPERIMENT – 4
Develop an ALP to find the sum of first 10 integer numbers.
AREA SUM1,CODE,READONLY
EXPORT__main
_main
MOV r1,#10; //counter of 10 numbers
MOV r2,#00; //OUTPUT gets stored
LOOP
ADDS R2,R2,R1; //r2=10
SUBS R1,R1,#01; // r1=9
CMP R1,#00
BNE LOOP; //checks r1=00
L BL
END
OUTPUT
EXPERIMENT – 5
Develop an ALP to find the largest/smallest number in an array of 32 numbers.
AREA LARGEST,CODE,READONLY
ENTRY
START
MOV R5,#6
LDR R1,=VALUE1
LDR R2,[R1],#4
LOOP
LDR R4,[R1],#4
CMP R2,R4
BHI LOOP1
MOVR2,R4
LOOP1
SUBS R5,R5,$1
CMP R5,#0
BNE LOOP
LDR R4,=RESULT
STR R2,[R4]
NOP
NOP
NOP
VALUE1
DCD 0X44444444
DCD 0X22222222
DCD 0X11111111
DCD 0X33333333
DCD 0XAAAAAAAA
DCD 0X88888888
DCD 0X99999999
AREA DATA2,DATA,READWRITE;
RESULT DCD 0X0
END
OUTPUT
EXPERIMENT – 6
Develop an ALP to count the number of ones and zeros in two consecutive memory
locations.
AREA ONEZERO,CODE,READONLY
ENTRY
START
MOV R2,#0
MOV R3,#0
MOV R7,#2
LDR R6,=VALUE
LOOP MOV R1,#32
LDR R0,[R6],#4
LOOP0 MOVS R0,R0,ROR #1
BHI ONES
ZEROS ADD R3,R3,#1
B LOOP1
ONES ADD R2,R2,#1
LOOP1 SUBS R1,R1,#1
BNE LOOP0
SUBS R7,R7,#1
;CMP R7,#0
BNE LOOP
BACK B BACK
VALUE DCD 0X11111111,0XAA55AA55
END
OUTPUT
EXPERIMENT – 7
Simulate a program in C for ARM microcontroller using KEIL to sort the numbers in
ascending/descending order using bubble sort.
AREA ASCENDING,CODE,READONLY
ENTRY
START
MOV R8,#4
LDR R2,=CVALUE
LDR R3,=DVALUE
LOOP0 LDR R1,[R2],#4
STR R1,[R3],#4
SUBS R8,R8,#1
;CMP R8,#0
BNE LOOP0
BACK B BACK
NOP
NOP
;ARRAY OF 32 BIT NUMBERS IN DATA REGION
CVALUE
DCD 0X44444444
DCD 0X11111111
DCD 0X33333333
DCD 0X22222222
AREA DATA1,DATA,READWRITE
EXPERIMENT – 8
Simulate a program in C for ARM microcontroller to find factorial of a number
OUTPUT
EXPERIMENT – 9
Simulate a program in C for ARM microcontroller to demonstrate case conversion of
characters from upper to lowercase and lower to uppercase.