0% found this document useful (0 votes)
12 views19 pages

ssse mc lab manual

Uploaded by

sssecsis25
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)
12 views19 pages

ssse mc lab manual

Uploaded by

sssecsis25
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/ 19

Channabasaveshwara Institute of Technology

(Affiliated to VTU, Belgaum & Recognized by A.I.C.T.E. New Delhi)


(An ISO 9001:2015 Certified Institution)
NH 206, (B.H. Road), Gubbi, Tumkur – 572 216. Karnataka

Department of Computer Science & Engineering

MICROCONTROLLER LABORATORY MANUAL

SEMESTER – IV

BCS402

FACULTY IN-CHARGE

Mr. Chethan Balaji Mrs. Deepika K S

Associate Professor Assistant Professor

Dept. of CSE
Channabasaveshwara Institute of Technology
(Affiliated to VTU, Belgaum & Approved by AICTE, New Delhi)
( ISO 9001:2015 Certified Institution)
NH 206 (B.H. Road), Gubbi, Tumkur – 572 216. Karnataka

Department of Computer Science & Engineering

LAB PROGRAMS LIST


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.
Course outcome (Course Skill Set)
CO1: Explain the ARM Architectural features and Instructions.
CO2: Develop programs using ARM instruction set for an ARM Microcontroller.
CO3: Explain C-Compiler Optimizations and portability issues in ARM Microcontroller.
CO4: Apply the concepts of Exceptions and Interrupt handling mechanisms in developing applications.
CO5: Demonstrate the role of Cache management and Firmware in Microcontrollers.

HOD
BCS402, MC-LAB IV Sem. CSE

PROGRAM NO.1
AIM: USING KEIL SOFTWARE, OBSERVE THE VARIOUS REGISTERS, DUMP,
CPSR, WITH A SIMPLE ASSEMBLY LANGUAGE PROGRAMS (ALP).

Code:

AREA Example, CODE, READONLY


ENTRY
MOV R0, #10 ; Load the value 10 into register R0
ADD R1, R0, #5 ; Add 5 to the value in R0 and store the result in R1
SUB R2, R1, #3 ; Subtract 3 from the value in R1 and store the result in R2
END
TRACING
R0=10;
R1=R0+5=10+5=15=0X0000000F;
R2=R1-3=15-3=12=0X0000000C;

RESULT: R1=R0+5=10+5=15=0X0000000F;
R2=R1-3=15-3=12=0X0000000C;

With a simple assembly language program the various registers, CPSR, has been observed using KEIL
software.

Page 1 of 38
BCS402, MC-LAB IV Sem. CSE

PROGRAM NO.2
AIM: DEVELOP AND SIMULATE ARM ALP FOR DATA TRANSFER, ARITHMETIC
AND LOGICAL OPERATIONS (DEMONSTRATE WITH THE HELP OF A SUITABLE
PROGRAM).

SAMPLE PROGRAM FOR DATA TRANSFER INSTRUCTIONS

AREA PROG1, CODE, READONLY

ENTRY

LDR R0,=0X40000000

LDR R1,[R0]

LDR R2,[R0,#4]

STR R2,[R0]

END

Tracing:

R0=0X40000000

R1=[0X40000000]=0X12345678

R2=[R0+4]= [0X40000000+4] =0X40000004=0X23242526

[R0]=[0X40000000]=R2=0X23242526

Page 2 of 38
BCS402, MC-LAB IV Sem. CSE

SAMPLE PROGRAM FOR ARITHMETIC INSTRUCTIONS

AREA PROG1, CODE, READONLY


ENTRY
LDR R1, =0X00000006

LDR R2, =0X00000002

ADD R4, R1, R2


ADC R5, R1, R2
SUB R6, R1, R2
SBC R8, R1, R2
RSB R7, R1, R2
RSC R3, R1, R2
END
TRACING
R1=0X00000006
R2=0X00000002
R4=R1+R2=0X00000008 (6+2=8)
R5=R1+R2+C=0X00000008(6+2+0)=8
R6=R1-R2=0X00000004(6-2=4)
R8=R1-R2-!C=0X00000003(6-2-!0=3)
R7=R2-R1=0XFFFFFFFC (2-6= -4 = 0XFFFFFFFC in hexadecimal)
R3=R2-R1-!C=2-6-1=-5=0XFFFFFFFB

RESULT: R4=0X00000008, R5=0X00000008, R6=0X00000004, R8=0X00000003,


R7=0XFFFFFFFC, R3=0XFFFFFFFB

Page 3 of 38
BCS402, MC-LAB IV Sem. CSE

1. SAMPLE PROGRAM FOR LOGICAL INSTRUCTIONS


AREA LOGIC,CODE,READONLY
ENTRY
MOV R1, #0X00000006
MOV R2, #0X00000004
ORR R3,R2,R1
AND R5,R1,R2
EOR R6,R1,R2
BIC R4,R1,R2
END
TRACING
R1=0X00000006
R2=0X00000004
R3=R2|R1=0X00000006
R5=R1&R2=0X00000004
R6=R1^R2=0X00000002
R4=R1&(!R2)=0X00000002
RESULT: R3=0X00000006, R5=0X00000004, R6=0X00000002, R4=0X00000002

Page 4 of 38
BCS402, MC-LAB IV Sem. CSE

4.WRITE AN ALP PROGRAM TO EVALUATE THE ARITHMETIC EXPRESSION


X= (A + C ) - D
AREA EX, CODE, READONLY
ENTRY
LDR R4,=A ; get address for A
LDR R0,[R4] ; get value of A
LDR R4, =C ; get address for C , reusing R4
LDR R1, [R4] ; get value of C
ADD R3,R0,R1 ; compute A+C
LDR R4, =D ; get address for D
LDR R2,[R4] ; get value of D
SUB R3,R3,R2 ; complete computation of X
LDR R4, =X ; get address for X
STR R3, [R4] ; store value of X
END
A DCD 0X45
C DCD 0X25
D DCD 0X05
AREA DATA1 ,DATA, READWRITE
X DCD 0
END
TRACING
R4=0X0000002C
R0=0X00000045
R4=0X0000002C
R1=0X00000025
R3=(0X45+0X25) = 0X0000006A
R4=0X00000034
R2=0X00000005
R3=R3-R2=0X00000065
R4=0X40000000
RESULT: R3=0X00000065 AND WITH MEMORY ADDRESS 0X40000000=0X00000065

Page 5 of 38
BCS402, MC-LAB IV Sem. CSE

PROGRAM NO.3
AIM: TO DEVELOP AN ALP TO MULTIPLY TWO 16-BIT BINARY NUMBERS.
PROGRAM
AREA MULTIPLY, CODE, READONLY
ENTRY
START
LDR R1,=0X1234
LDR R2,=0X2345
MUL R3,R2,R1
END
TRACING:
R1,=0X1234
R2,=0X2345
R3=R2*R1=1234*2345=2820404

RESULT: R3=0X02820404
An ALP to multiply two 16-bit binary numbers has been developed and result has been verified using KEIL
software.

Page 6 of 38
BCS402, MC-LAB IV Sem. CSE

PROGRAM NO.4
AIM: TO WRITE A PROGRAM TO FIND THE SUM OF THE FIRST 10 INTEGER
NUMBERS.
1+2+3+4+5+6+7+8+9+10=55=0X37
PROGRAM

AREA SUM, CODE, READONLY


ENTRY

MOV R0,#10 ;set the counter=10

MOV R1,#0 ; initialize the register to store result


MOV R2,#1 ;take 1st number to add

NEXT
ADD R1,R1,R2 ; add the numbers
ADD R2,#1 ; increment the integer
SUBS R0,#1 ; decrement counter
BNE NEXT ;branch to the loop if not equal to zero
END
TRACING:
R0=10=0XA
R1=0
R2=1
R1=R1+R2=0+1=1 R1=1+2=3 R1=3+3=6 R1=6+4=10=0XA
R2=R2+1=1+1=2 R2=2+1=3 R2=3+1=4 R2=4=1=5
R0=R0-1=10-1=9 R0=9-1=8 R0=8-1=7 R0=7-1=6

R1=10+5=15=0XF R1=15+6=21=0X16 R1=21+7=28=0X1C R1=28+8=36=0X24


R2=5+1=6 R2=6+1=7 R2=7+1=8 R2=8+1=9
R0=6-1=5 R0=5-1=4 R0=4-1=3 R0=3-1=2

Page 7 of 38
BCS402, MC-LAB IV Sem. CSE

R1=36+9=45=0X2D R1=45+10=55=0X37
R2=9+1=10 R2=10+1=11
R0=2-1=1 R0=1-1=0

RESULT: R1=55=0X37
Program to find the sum of the first 10 integer numbers has been executed and its result has
been verified.

Page 8 of 38
BCS402, MC-LAB IV Sem. CSE

PROGRAM NO.5
AIM: TO WRITE A PROGRAM TO FIND THE LARGEST OR SMALLEST NUMBER IN AN
ARRAY OF 32 NUMBERS.

AREA LARGEST,CODE,READONLY
ENTRY
MOV R5,#5
LDR R0,A
LDR R2,[R0]
NEXT ADD R0,#4
LDR R3,[R0]
CMP R2,R3
BHS LARGE
MOV R2,R3
LARGE SUBS R5,#1
BNE NEXT
LDR R1,RES
STR R2,[R1]
STOP B STOP
A DCD 0X40000000
RES DCD 0X40000020
END

Page 9 of 38
BCS402, MC-LAB IV Sem. CSE

TRACING:
R5=5
R0=0X40000000
R2=[0X40000000]=25
RO=0X40000004 RO=0X40000008
NEXT R3=[0X40000004]=33 R3=[0X40000008]=85
COMPARE 25 AND 33 IS 25>33 NO THEN IS 33>85 NO THEN
R2=R3=33 R2=R3=85
R5=4 (R5 !=1) THEN BRANCH TO NEXT R5=3 (R5 !=1) THEN BRANCH TO NEXT

RO=0X4000000C RO=0X40000010
R3=[0X4000000C]=99 R3=[0X40000010]=59
IS 85>99 NO THEN IS 99>59 TES THEN
R2=R3=99
R5=2 (R5 !=1) THEN BRANCH TO NEXT R5=1 (R5 !=0) THEN BRANCH TO NEXT

RO=0X40000014
R3=[0X40000014]=44
IS 44>99 NO THEN

R5=0 (R5 !=0) THEN


R1=0X40000020
R2=[0X40000020]=99

Page 10 of 38
BCS402, MC-LAB IV Sem. CSE

RESULT: R2=[0X40000020] = 99 for smallest number R2=25=[0x40000020]

Program to find the largest or smallest number in an array of 32 numbers has been executed and its result has
been verified.

Page 11 of 38
BCS402, MC-LAB IV Sem. CSE

PROGRAM NO.6
AIM: TO WRITE A PROGRAM TO COUNT THE NUMBER OF ONES AND ZEROS IN
TWO CONSECUTIVE MEMORY LOCATIONS.

AREA ONESS,CODE,READONLY
ENTRY
MOV R1,#0 ;counter for ones
MOV R2,#0 ;counter for zeros
MOV R3,#2 ;counter to set two words
LDR R4,=VALUE ;loads the address of value
LOOP2
MOV R5,#32
LDR R6,[R4],#4
LOOP0
MOVS R6,R6,ROR #1
BHI ONES
ADD R2,R2,#1
B LOOP1
ONES
ADD R1,R1,#1
LOOP1
SUBS R5,R5,#1
BNE LOOP0
Page 12 of 38
BCS402, MC-LAB IV Sem. CSE

SUBS R3,R3,#1
BNE LOOP2

STOP B STOP

VALUE DCD 0X3,0X2


END
TRACING:
R1=0
R2=0
R3=2
R4=0X00000040
R5=32 OR 0X00000020
R6=0X00000003, R4=0X00000044
R6=80000001 R6=0XC000000
IS C=1? YES BRANCH TO ONES IS C=1? YES BRANCH TO ONES
R1=0X00000001 R1=0X00000002
R5=0X0000001F OR 31 R5=0X0000001E OR 30
CHECKS R5=0 NO ITS 31 BRANCH TO LOOP0 CHECKS R5=0 NO ITS 31 BRANCH TO LOOP0

R6=0X60000000
IS C=1? NO ITS ZERO THEN
R2=0X00000001 BRANCH TO LOOP1 THEN
R5=0X0000001D OR 29
CHECKS R5=0 NO ITS 29 BRANCH TO LOOP0
THE LOOP WILL REPEAT UNTILL R5=0
RESULT:
No. of ones =3 = R1=0x00000003
No. of zeros = 61 =R2=0x0000003D
A program to count the number of ones and zeros in two consecutive memory locations has been executed and its
result has been verified.

Page 13 of 38
BCS402, MC-LAB IV Sem. CSE

PROGRAM NO.7
AIM: TO SIMULATE A PROGRAM IN C FOR ARM MICROCONTROLLER USING KEIL TO
SORT THE NUMBERS IN ASCENDING/DESCENDING ORDER USING BUBBLE SORT.
EMBEDDED C PROGRAM
#include <LPC214x.h>

void bubbleSort(int arr[], int n, int ascending);

int main(void) {
// Example array to sort
int arr[] = {64, 34, 25, 12, 22, 11, 90};
int n = sizeof(arr) / sizeof(arr[0]);

// Sort in ascending order


bubbleSort(arr, n, 1);

// Sort in descending order


// bubbleSort(arr, n, 0);

while (1) {
// Infinite loop
}
}

void bubbleSort(int arr[], int n, int ascending) {


int i, j;
for (i = 0; i < n - 1; i++) {
for (j = 0; j < n - i - 1; j++) {
if (ascending) {
if (arr[j] > arr[j + 1]) {
// Swap arr[j] and arr[j + 1]
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
} else {
if (arr[j] < arr[j + 1]) {
// Swap arr[j] and arr[j + 1]
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
}

Page 14 of 38
BCS402, MC-LAB IV Sem. CSE

PROGRAM NO.8
AIM: SIMULATE A PROGRAM IN C FOR ARM MICROCONTROLLER TO FIND FACTORIAL
OF A NUMBER.
EMBEDDED C PROGRAM

#include <LPC214x.h>

unsigned int factorial(unsigned int n);

int main(void) {
unsigned int number = 5; // Example number to find factorial of
unsigned int result;

result = factorial(number);

while (1) {
// Infinite loop
}
}

unsigned int factorial(unsigned int n) {


if (n == 0) {
return 1;
} else {
return n * factorial(n - 1);
}
}

Page 15 of 38
BCS402, MC-LAB IV Sem. CSE

VIVA QUESTIONS:

1. What is the processor used by ARM7?

a) 8-bit CISC b) 8-bit RISC

c) 32-bit CISC

d) 32-bit RISC

2. What is the instruction set used by ARM7?

a) 16-bit instruction set

b) 32-bit instruction set

c) 64-bit instruction set

d) 8-bit instruction set

3. How many registers are there in ARM7?

a) 35 register( 28 GPR and 7 SPR)

b) 37 registers(28 GPR and 9 SPR)

c) 37 registers(31 GPR and 6 SPR)

d) 35 register(30 GPR and 5 SPR)

Explanation: ARM7TDMI has 37 registers(31 GPR and 6 SPR). All these designs use a Von Neumann
architecture, thus the few versions comprising a cache do not separate data and instruction caches.

4. ARM7 has an in-built debugging device?

a) True

b) False

5. What is the capability of ARM7 f instruction for a second?

a) 110 MIPS

b) 150 MIPS

c) 125 MIPS

d) 130 MIPS

6. We have no use of having silicon customization?

a) True

b) False

7. Which of the following has the same instruction set as ARM7?

a) ARM6

b) ARMv3

Page 16 of 38
BCS402, MC-LAB IV Sem. CSE

c) ARM71a0

d) ARMv4T

8. What are t, d, m, I stands for in ARM7TDMI?

a) Timer, Debug, Multiplex, ICE

b) Thumb, Debug, Multiplier, ICE

c) Timer, Debug, Modulation, IS

d) Thumb, Debug, Multiplier, ICE

9. ARM stands for

a) Advanced RISC Machine

b) Advanced RISC Methadology

c) Advanced Reduced Machine

d) Advanced Reduced Methadology

10. What are the profiles for ARM architecture?

a) A,R b) A,M c) A,R,M d) R,M

11. ARM7DI operates in which mode?

a) Big Endian

b) Little Endian

c) Both big and little Endian

d) Neither big nor little Endian

12. In which of the following ARM processors virtual memory is present?

a) ARM7DI b) ARM7TDMI-S c) ARM7TDMI d) ARM7EJ-S

13. How many instructions pipelining is used in ARM7EJ-S?

a) 3-Stage b) 4-Stage c) 5-Stage d)2-stage

14. How many bit data bus is used in ARM7EJ-s?

a) 32-bit b) 16-bit c) 8- d) Both 16 and 32 bit

15. What is the cache memory for ARM710T?

a) 12Kb b) 16Kb c) 32Kb d) 8Kb

Page 17 of 38

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy