S.V.E.
Society’s
BHEEMANNA KHANDRE INSTITUTE OF TECHNOLOGY
BHALKI-585328
2023-2024
Department of Electronics and Communication Engineering
COA –IPCC Laboratory [21EC52]
LAB MANUAL
Prepared by: Mrs. Channabasamma Maka
[Link]
[Link] E&CE
PART-A
Conduct the following experiments by writing Assembly Language Program (ALP) using
ARM Cortex M3 Registers using an evaluation board/simulator and the required software
tool.
1. Write an ALP to A) multiply two 16 bit binary numbers. B) add two 64 bit numbers.
2. Write an ALP to find the sum of first 10 integer numbers.
3. Write an ALP to find factorial of a number.
4. Write an ALP to add an array of 16 bit numbers and store the 32 bit result in internal
RAM
5. Write an ALP to find the square of a number (1 to 10) using look-up table.
6. Write an ALP to find the largest/smallest number in an array of 32 numbers.
7. Write an ALP to arrange a series of 32 bit numbers in ascending/descending order.
8. Write an ALP to count the number of ones and zeros in two consecutive memory
locations.
PART-B
Conduct the following experiments on an ARM CORTEX M3 evaluation board using
evaluation version of Embedded 'C' & Keil Uvision-4 tool/compiler.
9. Interface a Stepper motor and rotate it in clockwise and anti-clockwise direction.
10. Interface a DAC and generate Triangular and Square waveforms.
11. Display the Hex digits 0 to F on a 7-segment LED interface, with an appropriate delay
in between.
12. Interface a simple Switch and display its status through Relay, Buzzer and LED.
PART-A
Conduct the following experiments by writing Assembly Language Program (ALP) using
ARM Cortex M3 registers using an evaluation board/simulator and the required software
tool.
1. A) Write an ALP to multiply two 16 bit binary numbers.
AREA MUL,CODE,READONLY
ENTRY
LDR R1,=0X1234
LDR R2,=0X2345
MUL R3,R1,R2
NOP
NOP
END
RESULT:
R1=0X00001234
R2=0X00002345
R3=0X02820404
1. B) Write an ALP to Add two 64 bit numbers.
AREA ADD,CODE,READONLY
ENTRY
LDR R0,VALUE11
LDR R1,VALUE12
LDR R2,VALUE21
LDR R3,VALUE22
ADDS R4,R0,R2
ADC R5,R1,R3
VALUE11 DCD 0X4321
VALUE12 DCD 0X1234
VALUE21 DCD 0X7896
VALUE22 DCD 0X6789
END
RESULT:
R0=0X00004321
R1=0X00001234
R2=0X00007896
R3=0X00006789
R4= 0x00008887
R5= 0x0000798D
2. Write an ALP to find the sum of first 10 integer numbers.
AREA ADD,CODE,READONLY
ENTRY
MOV R0,#10
MOV R1,#0
MOV R2,#1
NEXT ADD R1,R1,R2
ADD R2,#1
SUBS R0,#1
BNE NEXT
NOP
END
RESULT:
R0= 0X00000001
R1= 0X00000037
R2= 0X0000000A
3. Write an ALP to find factorial of a number.
AREA FACT,CODE,READONLY
ENTRY
MOV R0,#5
MOV R1,#1
CMP R0,#0
BEQ STOP
MOV R1,R0
NEXT SUBS R0,#1
CMP R0,#0
BEQ STOP
MUL R2,R1,R0
MOV R1,R2
B NEXT
STOP
NOP
END
RESULT:
R1= 0X00000078
[Link] an ALP to add an array of 16 bit numbers and store the 32 bit result in internal
RAM
AREA ADD,CODE,READONLY
ENTRY
START
LDR R0,=ARRAY
LDR R5,=SUM
MOV R1,#0
MOV R4,#0
NEXT CMP R1,#10
BEQ STORE
LDRH R3,[R0],#2
ADC R4,R4,R3
ADD R1,R1,#1
LOOP B NEXT
STORE STR R4,[R5]
STOP B STOP
AREA [Link],READONLY
ARRAY DCW
0X0011,0X0022,0X0033,0X0044,0X0055,0X0066,0X0077,0X0088,0X0099,0X00AA
ALIGN
AREA DATASEG2,DATA
SUM DCD 0
END
RESULT:
R0=0X0000004C
R1=0X0000000A
R3=0X000000AA
R4=0X000000A7
MEMORY:
0X400000000: A7 03 00 00
[Link] an ALP to find the square of a number (1 to 10) using look-up table.
AREA SQUARE,CODE,READONLY
LDR R0,=TABLE
LDR R1,=3
SUB R1,#1
ADD R0,R0,R1
LDR R2,[R0]
STOP B STOP
TABLE DCB 01, 04, 09, 16, 25, 36, 49, 64, 81, 100
END
RESULT:
R0= 0X0000001A
R1= 0X00000002
R2 = 0X04011009
6. Write an ALP to find the largest/smallest number in an array of 32 numbers.
AREA LARGE,CODE,READONLY
ENTRY
MOV R5,#6
LDR R1,=VALUE
LDR R2, [R1], #4
CMP R2, R3
BHI LOOP1
MOV R2, R3
LOOP1 SUBS R5, R5, #1
CMP R5, #0
BNE LOOP
LDR R4, =RESULT
STR R2, [R4]
STOP B STOP
VALUE DCD 0X44444444, 0X22222222, 0X11111111, 0X33333333, 0XAAAAAAAA
0X88888888, 0X99999999
AREA INFO, DATA, READWRITE
RESULT DCD 0X00000000
END
AREA SMALL,CODE,READONLY
ENTRY
MOV R5,#6
LDR R1, =VALUE
LDR R2, [R1], #4
LOOP LDR R3, [R1], #4
CMP R2, R3
BLS LOOP1
MOV R2, R3
LOOP1 SUBS R5, R5, #1
CMP R5, #0
BNE LOOP
LDR R4, = RESULT
STR R2, [R4]
STOP B STOP
VALUE DCD 0X44444444, 0X22222222, 0X11111111, 0X33333333, 0XAAAAAAAA,
0X88888888, 0X99999999
AREA INFO, DATA,READWRITE
RESULT DCD 0X00000000
END
7. Write an ALP to arrange a series of 32 bit numbers in ascending/descending order.
AREA ASC, CODE, READONLY
ENTRY
START
MOV R1, #4
LDR R2, =ARRAY
LDR R3, =DST
UP LDR R4, [R2], #4
STR R4, [R3], #4
SUBS R1, R1, #1
CMP R1, #0
BNE UP
MOV R7, #3
PASS
MOV R1, #3
LDR R0, =DST
COMP LDR R2, [R0]
LDR R3, [R0]
CMP R2, R3
BLS CHECK
STR R2, [R0], # -4
STR R3, [R0]
ADD R0, #4
CHECK
SUBS R1, R1, #1
CMP R1, #0
BNE COMP
SUBS R7, R7, #1
CMP R7, #0
BNE PASS
STOP B STOP
AREA SRC, DATA, READONLY
ARRAY DCD 0X33333333, 0X22222222, 0X99999999, 0X55555555
ALIGN
AREA DST, DATA
SPACE 10
ALIGN
END
RESULT:
MEMORY : 0X40000000 : 22 22 22 22 33 33 33 33 55 55 55 55 99 99 99 99
AREA DSC, CODE, READONLY
ENTRY
START
MOV R1, #4
LDR R2, =ARRAY
LDR R3, =DST
UP LDR R4, [R2], #4
STR R4, [R3], #4
SUBS R1, R1, #1
CMP R1, #0
BNE UP
MOV R7, #3
PASS
MOV R1, #3
LDR R0, =DST
COMP LDR R2, [R0]
LDR R3, [R0]
CMP R2, R3
BHI CHECK
STR R2, [R0], # -4
STR R3, [R0]
ADD R0, #4
CHECK
SUBS R1, R1, #1
CMP R1, #0
BNE COMP
SUBS R7, R7, #1
CMP R7, #0
BNE PASS
STOP B STOP
AREA SRC, DATA, READONLY
ARRAY DCD 0X33333333, 0X22222222, 0X99999999, 0X55555555
ALIGN
AREA DST, DATA
SPACE 10
ALIGN
END
RESULT:
MEMORY : 0X40000000 : 99 99 99 99 55 55 55 55 33 33 33 33 22 22 22 22
8. Write an ALP to count the number of zero’s and one’s in two consecutive memory
location.
AREA NUM,CODE,READONLY
MOV R0,#0
MOV R1,#0
MOV R3,#16
MOV R2,#0X0005
BACK LSRS R2,#1
BCS NEXT
ADD R0,R0,#1
B STOP
NEXT ADD R1,R1,#1
SKIP SUB R3,R3,#1
CMP R3,#0
BNE BACK
STOP B STOP
END
RESULT:
RO=0X00000001
R1=0X00000001
R2= 0X00000001
R3=0X0000000F
PART-B:
Conduct the following experiments on an ARM CORTEX M3 evaluation board using
evaluation version of Embedded 'C' & Keil Uvision-4 tool/compiler.
9. Interface a Stepper motor and rotate it in clockwise and anti-clockwise direction.
# include<lpc17XX.h>
void pwm_init(void)
void pwm1_IRQHandler(void);
unsigned long int I;
unsigned char flag, flag1;
int main(void)
pwm_init(void);
while (1);
void pwm_init(void)
LPC_SC->PCONP = (1<<6);
LPC_ PINCON->PINSEL3 = 0X00020000;
LPC_PWM1->PR = 0X00000000;
LPC_PWM1->PCR = 0X00020000;
enabled
LPC_PWM1->MCR = 0X00000003;
LPC_PWM1->MRO = 6000;
LPC_PWM1->MR5 = 0X00000100;
LPC_PWM1->LER = 0X0000000FF;
LPC_PWM1->TCR = 0X00000002;
LPC_PWM1->TCR = 0X00000009;
NVIC_EnableIRQ(PWM1_IRQn);
Void pwm1_IRQHandler(void)
LPC_PWM1->IR = 0Xff;
If (flag == 0x00)
LPC_PWM1->MR5 +=100;
LPC_PWM1->LER = 0X000000FF;
if (LPC_PWM1->MR5>= 57000)
flag1 = 0xff;
flag = 0xff;
LPC_PWM1->LER = 0X000000FF;
for(i=0; i<8000; i++);
else if (flag1== 0xff)
LPC_PWM1->MR5 -= 100;
LPC_PWM1->LER = 0X000000FF;
IF(LPC_PWM1->MR5 <= 0X300)
Duty cycle MR= 300
flag = 0x00;
flag1 = 0x00;
LPC_PWM1->LER = 0X000000FF;
for(i=0; i<8000;i++);
10. Interface a DAC and generate Triangular and Square waveforms.
generation of square wave
#include <LPC17xx.H>
void delay(void);
int main()
LPC_PINCON->PINSELO &= 0XFF0000FF;
LPC_GPIOO->FIODIR = 0X00000FF0;
LPC_GPIOO-> FIOMASK = 0XFFFFF00F;
while(1)
LPC_GPIOO->FIOPIN = 0X00000FF0;
delay () ;
LPC_GPIOO->FIOCLR = 0X00000FF0;
delay () ;
void delay(void)
{
unsigned int i=0;
for (i=0;i<=9500; i++)
generation of triangular wave
#include <LPC17xx.H>
int main()
unsigned long int temp = 0x00000000;
unsigned int i= 0;
LPC_PINCON->PINSELO &= 0XFF0000FF;
to PO.11 as GPIO
LPC_GPIOO->FIODIR l = 0X00000FF0;
LPC_GPIOO->FIOMASK = 0XFFFFF00F;
while(1)
for(i=0; i! = 0XFF; i++)
temp =i;0
temp = temp <<4;
LPC_GPIOO->FIOPIN = temp;
for(i=0xFF; i!=0; i--)
{
temp =i;0
temp = temp <<4;
LPC_GPIOO->FIOPIN = temp;
11. Display the Hex digits 0 to F on a 7-segment LED interface, with an appropriate delay
in between.
#include <LPC17xx.h>
Unsigned int delay,count=0, switchcount=0,j;
Unsigned int Disp[16]={0X000003f0, 0X00000060, 0X000005b0, 0X000004f0, 0X00000660,
0X000006d0,0X000007d0, 0X00000070, 0X000007f0,
0X000006f0, 0X00000770,0X000007c0,
0X00000390, 0X000005e0, 0X00000790, 0X00000710
#define ALLDISP 0X00180000
#define DATAPORT 0X00000FF0
Int main (void )
LPC_PINCON->PINSELO = 0x00000000;
LPC_PINCON->PINSEL1 = 0x00000000;
LPC_GPIOO->FIODIR = 0x00180FF0;
While(1)
LPC_GPIOO->FIOSET l= ALLDISP;
LPC_GPIOO->FIOCLR = 0x00000FF0;
LPC_GPIOO->FIOSCT = Disp [switchcount];
7-segment display value from the array
for(j=0;j<3;j++)
for(delay=0;delay<30000;delay++);
switchcount++;
if(switchcount == 0X10)
Switchcount=0;
LPC_GPIOO->FIOCLR = 0x00180FF0;
12. Interface a simple Switch and display its status through Relay, Buzzer and LED.
#include <LPC17xx.h>
Int main(void)
LPC_PINCON->PINSEL1 =0X00000000;
LPC_GPIOO->FIODIR =0X03000000;
While(1)
If(!( LPC_GPIO2->FIOPIN & 0X00000800))
{
LPC_GPIOO->FIOSET =0X03000000;
Else
LPC_GPIOO->FIOCLR =0X03000000;