LAB Manual-1
LAB Manual-1
LAB Manual-1
LABORATORY
[As per Choice Based Credit System (CBCS) scheme]
SEMESTER - VI
Laboratory Code 21CS43
CIE Marks 50 SEE Marks 50
Course outcomes:
On the completion of this laboratory course, the students will be able to:
Develop and test program using ARM7TDMI/LPC2148.
1. Engineering Knowledge
2. Problem Analysis
2. Design/Development of Solutions
3. Modern Tool Usage
Conduction of Practical Examination:
PART-A
Experiment no 1
Write a program to multiply two 16 bit binary numbers.
;/* PROGRAM TO MULTIPLY TWO 16BIT NUMBERS */
;/* SET A BREAKPOINT AT NOP INSTRUCTION,RUN THE PROGRAM & CHECK THE
RESULT */
START
NOP
NOP
NOP
Results:
Experiment no 2
Write a program to find the sum of first 10 integer numbers
XSS B XSS
Experiment no 3
START
BEQ STOP
STOP
NOP
NOP
NOP
Experiment no 4
Write a program to add an array of 16 bit numbers and store the 32 bit result in internal
RAM
;/* Program To Add An Array Of 16bit Numbers & Store In Internal Ram*/
;/* The Sum Is 29997h The Result Can Be Viewed In Location 0x40000000 & Also In R0*/
;/* Set A Breakpoint At Nop Instruction,Run The Program & Check The Result */
START
LOOP
CMP R5,#0 ;
NOP
NOP
NOP
Results
Experiment no 5
Write a program to find the square of a number (1 to 10) using look-up table.
;/* Set A Breakpoint At Nop Instruction,Run The Program & Check The Result */
START
NOP
NOP
NOP
Results
Experiment no 6
Write a program to find the largest/smallest number in an array of 32 numbers .
;/* program to find largest number in an array & store in internal ram*/
;/*0x88888888 ,0x99999999*/
;/* set a breakpoint at nop instruction, run the program & check the result */
START
LOOP
LOOP1
NOP
Dept of CSE/ISE,Mycem Page 11
MICROCONTROLLER AND EMBEDDED SYSTEMS LABORATORY [18CSL48]
NOP
NOP
VALUE1
DCD 0X44444444 ;
DCD 0X22222222 ;
DCD 0X11111111 ;
DCD 0X33333333 ;
DCD 0XAAAAAAAA ;
DCD 0X88888888 ;
DCD 0X99999999 ;
;/* Program To Find Smallest Number In An Array & Store In Internal Ram */
;/*0x88888888 ,0x99999999 */
;/* Set A Breakpoint At Nop Instruction,Run The Program & Check The Result */
START
LOOP
LOOP1
NOP
NOP
NOP
VALUE1
DCD 0X44444444 ;
DCD 0X22222222 ;
DCD 0X11111111 ;
DCD 0X22222222 ;
DCD 0XAAAAAAAA ;
DCD 0X88888888 ;
DCD 0X99999999 ;
Results
11111
11 11 11 11
Experiment no 7
Write a program to arrange a series of 32 bit numbers in ascending/descending order.
;/* Set A Breakpoint At Nop Instruction,Run The Program & Check The Result /*
START
LOOP0
NOP
NOP
NOP
CVALUE
DCD 0X44444444 ;
DCD 0X11111111 ;
DCD 0X33333333 ;
DCD 0X22222222 ;
DVALUE
DCD 0X00000000 ;
;/* Set A Breakpoint At Nop Instruction,Run The Program & Check The Result /*
START
LOOP0
NOP
NOP
NOP
CVALUE
DCD 0X44444444 ;
DCD 0X11111111 ;
DCD 0X33333333 ;
DCD 0X22222222 ;
DVALUE
DCD 0X00000000 ;
Experiment no 8
Write a program to count the number of ones and zeros in two consecutive memory
locations.
START
ZEROS
ADD R3,R3,#1 ;If Carry Bit Is 0 Then Increment The Counter By 1(R3)
ONES
LOOP1
XSS B XSS
Part -B
Program 9:
#include "Serial.h"
int j=0,i=0;
for(j=0;j<count;j++)
for(i=0;i<35;i++);
delay_ms(100000);
while (1)
delay_ms(1000000);
Program 10:
Interface and Control a DC Motor.
//**********************************************************************
// Microcontroller : LPC2148
// Pin Connection P1.30 and P1.31 pins of Port-0 connected to L293D IC(DC
motor driver)
//**********************************************************************
void delay(void);
void dc_clock(void);
void dc_A_clock(void);
int main()
while(1)
delay();delay();delay();
dc_clock();
for(i=0;i<1000;i++)
for(j=0;j<1000;j++);
IOSET1 = 0x80000000;
delay();
IOCLR1 = 0x80000000;
delay();
IOSET1 = 0x40000000;
delay();
IOCLR1 = 0x40000000;
delay();
Program 11:
//****************************************************************************
// Microcontroller : LPC2148
// Description :Stepper Motor Roatating Clockwise direction after certain delay roatating
Anticlockwise direction
//****************************************************************************
#include<lpc214x.h>
void delay(void);
void stepper_clock(void);
void stepper_A_clock(void);
int main()
while(1)
{
stepper_clock(); // stepper motor clock Fuction calling (P0.28 to P0.31 port pins connected
to stepper motor)
stepper_A_clock(); // stepper motor anti clock Fuction calling (P0.28 to P0.31 port
pins connected to stepper motor)
delay();delay();delay(); // Fuction call (P0.28 to P0.31 port pins connected to stepper motor)
}
}
for(i=0;i<1000;i++)
for(j=0;j<1000;j++);
}
}
void stepper_clock(void) // stepper motor clockwise rotation sub program
IOSET0 = 0x30000000;
delay();
IOCLR0 = 0x30000000;
delay();
IOSET0 = 0x60000000;
delay();
IOCLR0 = 0x60000000;
delay();
IOSET0 = 0xC0000000;
delay();
IOCLR0 = 0xC0000000;
delay();
IOSET0 = 0x90000000;
delay();
IOCLR0 = 0x90000000;
delay();
}
Program 4: Determine Digital output for a given Analog input using Internal ADC
of ARM controller.
#include<lpc214x.h>
#define rs 0x00400000
#define rw 0x20000000
#define en 0x10000000
float voltage;
char volt[18];
for(i=0;i<x;i++)
for(j=0;j<1275;j++)
IOCLR0=0x00003fc0;
IOSET0=c<<6;
IOCLR0=rw;
IOCLR0=rs;
IOSET0=en;
delay(100);
IOCLR0=en;
IOCLR0=0x00003fc0;
IOSET0=c<<6;
IOCLR0=rw;
IOSET0=rs;
IOSET0=en;
delay(100);
IOCLR0=en;
while(*s)
data(*s);
s++;
delay(20);
void adc_init()
AD0CR=0x00210308;
PINSEL1=0x10000000;
if(n==0)
data(n+0x30);
if(n)
display(n/10);
data((n%10)+0x30);
void init()
cmd(0x38);
cmd(0x0e);
cmd(0x01);
void main()
IODIR0|=0x30403fc0;
init();
adc_init();
while(1)
cmd(0x01);
lcd_str("ADC:");
cmd(0x84);
display(result);
sprintf(volt,"voltage:%.2f V",voltage);
cmd(0xc0);
lcd_str(volt);
delay(1000);
Program 5:
Interface a DAC and generate Triangular and Square waveforms.
/* Triangle wave */
#include "LPC214X.h"
int main()
PINSEL1|=0x00080000;
while(1)
value = 0;
value++;
while ( value != 0 )
value--;
/* square wave /*
#include "LPC214X.h"
int main()
PINSEL1|=0x00080000;
while(1)
while(1)
val =0xFFFFFFFF;
DACR=val;
break;
while(1)
{
val =0x00000000;
DACR=val;
break;
Program 6:
Interface a 4x4 keyboard and display the key code on an LCD.
#include "lcd.h"
// 0 1 2 3 ROW 1
// 4 5 6 7 ROW 2
// 8 9 A B ROW 3
// C D E F ROW 4
KEY_CTRL_CLR |= COLMASK;
KEY_CTRL_SET |= temp;
'4','8','B','F',
'3','7','A','E',
'2','6','0','D',
'1','5','9','C'
};
init_lcd();
while (1)
key = 0;
col_write(rval[i]);
break;
key++;
break;
key++;
break;
key++;
break;
key++;
if (key == 0x10)
else
{ lcd_gotoxy(1,14);
lcd_putchar(keyPadMatrix[key]);
Program 7:
Demonstrate the use of an external interrupt to toggle an LED On/Off.
#include <LPC214x.H>
int i;
//The _irq keyword tells the compiler that the function is an interrupt routine
IO1DIR |= 0x00010000;
IO1CLR |= 0x00010000;
for(i=0; i<3000000;i++);
IO1SET |= 0x00010000;
// Basically Vector Address Register store the address of the function i.e. ISR and used to assign
or enable vector IRQ slot..Pointer Interrupt Function (ISR)
while(1);
Program 8:
Display the Hex digits 0 to F on a 7-segment LED interface, with an appropriate
delay in between
#include <LPC214x.H>
int main(void)
IO0DIR = 0x000007FC;
while(1)
IO0CLR = 0x00000FFF;
IO0SET = 0x00000604;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x000007E4;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x00000648;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x00000618;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x00000730;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x00000690;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x00000680;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x0000063C;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x00000600;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x00000630;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x00000620;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x00000780;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x000006C4;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x00000708;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x000006C0;
delay_led(150000);
IO0CLR = 0x00000FFF;
IO0SET = 0x000006E0;
delay_led(150000);
IO0CLR = 0x00000FFF;
void main()
{ IO1DIR=0x0F000000;
while(1)
IO1CLR=0x01000000;
IO1SET=0x01000000;
#include<LPC214x.h>
void main()
IO1DIR=0x0F000000;
while(1)
IO1CLR=0x02000000;
IO1SET=0x02000000;
// BLINKING an LED
#include <LPC214x.H>
int main(void)
IO1DIR = 0x00FF0000;
while(1)
IO1CLR = 0x00FF0000;
delay_led(150000);
IO1SET = 0x00FF0000;
delay_led(150000);
#include "LPC214x.h"
253,252,249,244,239,233,225,217,208,198,187,176,164,152,139,127,115,102,90,78,67,56,46,
37,29,21,15,10,5,2,1,0,1,2,5,10,15,21,29,37,46,56,67,78,90,102,115};
int main()
int i;
PINSEL1|=0x00080000;
while(1)
for(i=0;i<64;i++)
DACR=result;
VIVA QUESTIONS
1. What is Microcontroller?
2. List out the differences between Microcontroller and Microprocessor.
3. How are Microcontrollers more suitable than Microprocessor for Real Time
Applications?
4. What are the General Features of Microcontroller?
5. ARM stands for _________
6. How many registers are there in ARM7?
7. Explain the main features of the ARM Instruction Set.
8. Explain six operating modes of ARM.
9. Explain data processing Instructions of ARM.
10. Explain the following assembler directives
i) AREA ii) CODE iii) DATA iv) READONLY v)READWRITE
11. Explain the Features of LPC2148
12. What is an embedded system?
13. What are the components of embedded system?
14. Why we use embedded systems?