Professional Documents
Culture Documents
Embedded and Iot Lab-20.02.2024
Embedded and Iot Lab-20.02.2024
LABORATORY MANUAL
Academic Year:___________
INDEX
Exp. Page Marks Faculty
Date Name of the Experiment
No. No. Awarded Signature
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
EXPERIMENTS USING 8051.
OPERATIONS in 8051
EXPT NO:
DATE:
8 BIT ADDITION
AIM:
To write a program to add two 8-bit numbers using 8051 microcontroller.
ALGORITHM:
FLOW CHART:
START
Clear PSW
Select Register
Add A & R 0
STOP
8 Bit Addition (Immediate Addressing)
ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS
CODE
4100 CLR C C3 Clear CY Flag
OUTPUT
MEMORY LOCATION DATA
4500
RESULT:
Thus the 8051 ALP for addition of two 8 bit numbers is executed.
8 BIT SUBTRACTION
AIM:
To perform subtraction of two 8 bit data and store the result in memory.
ALGORITHM:
a. Clear the carry flag.
b. Initialize the register for borrow.
c. Get the first operand into the accumulator.
d. Subtract the second operand from the accumulator.
e. If a borrow results increment the carry register.
f. Store the result in memory.
FLOWCHART:
START
CLEAR CARRY
FLAG
GET I’ST
OPERAND IN
ACCR
SUBTRACT THE
2’ND OPERAND
FROM ACCR
N
IS CF=1
Y
INCREMENT
THE BORROW
REGISTER
STORE
RESULT IN
MEMORY
STOP
8 Bit Subtraction (Immediate Addressing)
ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS
CODE
4100 CLR C C3 Clear CY flag
OUTPUT
MEMORY LOCATION DATA
4500
RESULT:
Thus the 8051 ALP for subtraction of two 8 bit numbers is executed.
8 BIT MULTIPLICATION
AIM:
To perform multiplication of two 8 bit data and store the result in memory.
ALGORITHM:
a. Get the multiplier in the accumulator.
b. Get the multiplicand in the B register.
c. Multiply A with B.
d. Store the product in memory.
FLOWCHART:
START
GET
MULTIPLIER
IN ACCR
GET
MULTIPLICAND
IN B REG
MULTIPLY A
WITH B
STORE
RESULT IN
MEMORY
STOP
8 Bit Multiplication
ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS
CODE
4100 MOV A ,#data1 74, data1 Store data1 in
accumulator
4102 MOV B, #data2 75,data2 Store data2 in B reg
INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA
4500 4502
4501 4503
RESULT:
Thus the 8051 ALP for multiplication of two 8 bit numbers is executed.
8 BIT DIVISION
AIM:
To perform division of two 8 bit data and store the result in memory.
ALGORITHM:
1. Get the Dividend in the accumulator.
2. Get the Divisor in the B register.
3. Divide A by B.
4. Store the Quotient and Remainder in memory.
FLOWCHART:
START
GET DIVIDEND
IN ACCR
GET DIVISOR IN
B REG
DIVIDE A BY B
STORE
QUOTIENT &
REMAINDER
IN MEMORY
STOP
8 Bit Division
ADDRESS LABEL MNEMONIC OPERAND HEX COMMENTS
CODE
4100 MOV A, # data1 74,data1 Store data1 in
accumulator
4102 MOV B, # data2 75,data2 Store data2 in B reg
INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA
4500 (dividend) 4502 (remainder)
RESULT:
Thus the 8051 ALP for division of two 8 bit numbers is executed.
LOGICAL AND BIT MANIPULATION
AIM:
To write an ALP to perform logical and bit manipulation operations using 8051
microcontroller.
APPARATUS REQUIRED:
8051 microcontroller kit
ALGORITHM:
FLOWCHART:
START
STOP
PROGRAM TABLE
4502H (SCON) SM0 SM1 SM2 REN TB8 RB8 TI RI 0FH 20H
RESULT:
EXPT NO:
DATE:
AIM:
To convert Square and Cube program, Find 2’s complement of a number using 8051
micro controller
RESOURCES REQUIERED:
8051 microcontroller
kit Keyboard
Power supply
PROGRAM:
Org 0000h; sets the program counter to 0000h
Mov b,a; lower byte obtained is moved from 'a' to 'b' mov
r2,b; move value of 'b' to r2
RESULT:
Thus the Square and Cube program, Find 2’s complement of a number is done in 8051
microcontroller
PROGRAMMING USING ON – CHIP PORTS IN 8051
EXPT NO:
DATE:
AIM:
RESOURCES REQUIERED:
8051 microcontroller kit
Keyboard
Power supply
PROGRAM:
i. To generate 1second delay continuously using on chip
MOV TMOD,#02H
MOV TH0,#00H
CLR P1.0
CLR A
SETB TR0
CLR TF0
DJNZ R6,WAIT
DJNZ R7,LOOP
CPL P1.0
SJMP AGAIN
END
ii.Write an ALP to toggle the content of port 0 continuously using timer delay in
between.
Operands Comments
ORG 0000H
LJMP 8000H
ORG 8000H
HERE: JNB TF0, HERE ;if TF0 is not equal 1 then jump to here
RESULT:
EXPT NO:
DATE:
AIM:
To write a program to verify 8051 UART and check transmission and reception
APPARATUS REQUIRED:
2. Power supply
3. Interface cable
ALGORITHM:
8051 TRANSMITTER:
ADDRESS LABEL MNEMONICS COMMENTS
4100 MOV TMOD,#20H
4103 MOV THI,#0A0H
4106 MOV TLI,#00H
4109 MOV TCON,#40H
410C MOV SCON,#58H
410F MOV DPTR,#4500H
4112 RELOAD MOV R5,#05H
4114 REPEAT MOVX A,@DPTR
4115 MOV SBUF,A
4117 CHECK JNB SCON.1,CHECK
411A CLR SCON.1
411C INC DPTR
411D CJNE A,#3FH,RELOAD
4120 DJNZ R5,REPEAT
4122 CLR A
4123 LCALL 0020H
4126 HERE SJMP HERE
RECEPTION
4500:23 4500:23
4501:34 4501:34
4502:43 4502:43
4503:12 4503:12
RESULT:
Thus the assembly language program to perform 8051 serial communication was successfully executed and verified
. DESIGN OF A DIGITAL CLOCK USING TIMERS/COUNTERS IN 8051
EXPT NO:
DATE:
AIM:
APPARATUS REQUIRED:
2. Power supply
3. Interface cable
PROGRAM:
Assembly language program for 8051 microcontroller to display Seconds at Port A, Minutes at port
B and Hours at port C of 8255 PPI.
9100 1day: MOV DPTR,#2023H ; Load DPTR with Control port Address of 1st 8255
9103 MOV A, #80 ; (A) = 80H = control word for all ports as output ports
9105 MOV DPTR, #2022H; Load DPTR with port C Address of 1st 8255
9108 MOV R0, #0 ; (R0) = 00, to display 00 hours
910A MOV A,R0 ; (A) = (R0)
910B MOVX @DPTR,A ; Display 00 hours at port C of 8255
910C BACK3: MOV R4,#0 ; (R4) = 00, to display 00 minute
910E MOV A,R4 ; (A) = (R4)
910F MOV DPTR,#2021H ; Load DPTR with port B Address of 1st 8255
9112 MOVX @DPTR,A ; Display minutes at port B of 1st8255
9113 BACK2: MOV R3,#0 ; (R3) = 00, to display 00 Seconds
9115 MOV A,R3 ; (A) = (R3)
9116 MOV DPTR,#2020H ; Load DPTR with port A Address of 1st 8255
9119 BACK1: MOVX @DPTR,A ; Display Seconds at port A of 1st 8255
911A LCALL DELAY ; Call 1 second DELAY routine
911D ADD A,#01 ; (A) = (A) + 1, to get next second
911F DA A ; Decimal adjusting A to get seconds in BCD format
9120 CJNE A,#60H,BACK1 ; If (A) ≠ 60H, then jum to BACK1
9123 INC R4 ; (R4) = (R4) + 1, to get next minute
9124 MOV DPTR,#2021H ; Load DPTR with port B Address of 1st 8255
9127 MOV A,R4 ; (A) = (R4)
9128 DA A ; Decimal adjusting A to get minutes in BCD format
9129 MOVX @DPTR,A ; Display minutes at port B of 1st 8255
912A CJNE A,#60H,BACK2 ; If (A) ≠ 60H, then jump to BACK1
912D INC R0 ; (R0) = (R0) + 01, to get next hour
912E MOV A,R0 ; (A) = (R0)
912F DA A ; Decimal adjusting A to get hours in BCD format
9130 CJNE A,#24H,BACK2 ; If (A) ≠ 24H, then jump to BACK3
9133 RET ; Return to main program
RESULT:
Thus the assembly language program to perform Digital clock was successfully executed and verified
Ex. No: INTERFACING ADC AND DAC
Date:
AIM:
To develop and verify the interfacing ADC and DAC with LPC 2148 ARM
microcontroller.
APPARATUS REQUIRED:
2 IAR Workbench - 1
3 Flash magic - 1
4 WINXTALK - 1
5 Serial cable - 1
PROCEDURE:
Step 1: Give a double click on IAR Workbench on the desk top, it will
generate a window as shown below
Step 2: To create new project go to project select new micro vision project.
Step 3: select a drive where you would like to create your project.
Step 4: Create a new folder and name it with your project name.
Step 5: Open that project folder and give a name of your project executable
and save it.
Step 6: After saving it will show some window there you select your
microcontroller company i.e. NXP from Phillips
Step 8: After selecting chip click on OK then it will display some window
asking to add STARTUP. Select YES.
Step 10: To write your project code select a new from menu bar.
Step 11: It will display some text editor, to save that select SAVE
option from menu bar.
Step 13: Write the code of your project and save it.
Step 14: To add the c to target give a right click on Source Group,
choose “ADD s to Group” option.
Step 15: It will display some window there select the file and
click on ADD option.
Step 16: It will be added to our target and it shows in the project
window.
Step 17: Select right click on target in the project window and select
“Options for Target.”
Step 18: It will show some window, in that go to output option and choose
Create Hex option by selecting that box.
Step 20: Now to compile your project go to Project select Build Target
option or press F7.
Step 21: Check the concern block of output and observe the results.
PROGRAM:
#include <lpc214x.h>
#include <stdio.h> #define
ESC 0x1B
*/
*/
void delay(int n)
for(j=0;j<0x5000;j++)
{;}
}}
void main(void)
30 Mhz
serial_init(); //serial
initialization
ADC_CH = 1;
printf("%c[2J%c[H",ESC,ESC);
underline */
ADC_CH++;
delay(10);
for (i=1;i<4;i++)
{
delay(1); printf("ADC0.%d :
[",i);putchar(0x1B);
printf ("\xF8\F") ;
printf(" :: ");
delay(1);
{
ADC_CH = 1;
AD0CR = PRESET | (1<<ADC_CH);
AD0CR |= START;
//printf ("\b\b"); U0THR =
'\r';
}}
OUTPUT:
RESULT:
Thus the interfacing of ADC and DAC (In-built) with ARM processor has been
verified and observed the output successfully.
Ex. No: INTERFACING LED AND PWM.
Date:
AIM:
To develop and verify the interfacing LED and PWM with ARM DEVELOPMENT
KIT microcontroller using embedded c program.
APPARATUS REQUIRED:
2 IAR Workbench - 1
3 Flash magic - 1
4 WINXTALK - 1
5 Serial cable - 1
PROCEDURE:
Step 1: Give a double click on IAR Workbench icon on the desk top,
it willgenerate a window as shown below
Step 2: To create new project go to project select new micro vision project.
Step 3: select a drive where you would like to create your project.
Step 4: Create a new folder and name it with your project name.
Step 5: Open that project folder and give a name of your project executable
and save it.
Step 6: After saving it will show some window there you select your
microcontroller company i.e NXP from Phillips
Step 8: After selecting chip click on OK then it will display some window
asking to add STARTUP. Select YES.
Step 10: To write your project code select a new from menu bar.
Step 11: It will display some text editor, to save that select SAVE
option from menu bar.
Step 12: By giving a name with extension .C and save it
Step 13: Write the code of your project and save it.
Step 14: To add our c to target give a right click on Source Group,
choose “ADD s to Group” option.
Step 15:It will display some window there select the file and click on ADD option.
Step 16: It will be added to our target and it shows in the project
window.
Step 17: Select a right click on target in the project window and select
“Options for Target”
Step 18: It will show some window, in that go to output option and choose
Create Hex option by selecting that box
Step 19: In the same window go to Linker option and choose Use Memory
Layout from Target Dialog by selecting the box, and click OK.
Step 20: Now to compile your project go to Project select Build Target
option or press F7.
PROGRAM:
LED:
#include <LPC214x.h>
#include <stdio.h> #define
LED 16
- P1.31 as GPIO
IO1DIR = 0x00 << Switch; //Configure P1.24
- P1.31 as Input
IO1DIR |= 0xFF << LED; //Configure P1.16 -P1.23
as Output
IO1PIN = 0;
while(1)
Status = 1;
IOSET1 = 0xFF << LED;
} } }
void Delay(int n)
int p,q;
for(p=0;p<n;p++)
for(q=0;q<0x9990;q++);
PWM: }}
#include <LPC214x.H> /* LPC21xx
definitions */
#include <stdio.h>
VICVectAddr = 0x00000000;
*/
prescaler */
}void Delay ()
{
for (j=0;j<700;j++);
init_PWM();
U1LCR = 0x83;
U1DLL = 0xC3;
U1LCR = 0x03;
while (1)
{ /*
Loop forever */
do
PWMMR2 = val;
PWMLER = 0xF;
oldval = val;
OUTPUT:
Thus the interfacing of LED and PWM with ARM DEVELOPMENT KIT was done
by using embedded C program.
Ex. No: INTERFACING KEYBOARD AND LCD
Date:
AIM:
To develop and verify the interfacing of keyboard and LCD with ARM
DEVELOPMENT KIT ARM microcontroller using embedded C program.
APPARATUS REQUIRED:
2 IAR Workbench - 1
3 Flash magic - 1
4 WINXTALK - 1
5 Serial cable - 1
PROCEDURE:
Step 1: Give a double click on µvision 4 icon on the desk top, it will
generate a window as shown below
Step 2: To create new project go to project select new micro vision project.
Step 3: select a drive where you would like to create your project.
Step 4: Create a new folder and name it with your project name.
Step 5: Open that project folder and give a name of your project executable
and save it.
Step 6: After saving it will show some window there you select your
microcontroller company i.e NXP from Phillips
Step 8: After selecting chip click on OK then it will display some window
asking to add STARTUP. Select YES.
Step 10: To write your project code select a new from menu bar.
Step 11: It will display some text editor, to save that select SAVE
option from menu bar.
Step 12: By giving a name with extension .C and save it
Step 13: Write the code of your project and save it.
Step 14: To add our c to target give a right click on Source Group,
choose “ADD s to Group” option.
Step 15:It will displays some window there select the you have to add
and click on ADD option.
Step 16: It will be added to our target and it shows in the project
window.
Step 17: Now give a right click on target in the project window and select
“Options for Target”
Step 18: It will show some window, in that go to output option and choose
Create Hex option by selecting that box
Step 19: In the same window go to Linker option and choose Use Memory
Layout from Target Dialog by selecting the box, and click OK.
Step 20: Now to compile your project go to Project select Build Target
option or press F7.
Step 21: Ensure the output of keyboard and display as by pressing the keys simultaneously
PROGRAM:
KEYBOARD:
'4','5','6','7',
'8','9','A','B',
'C','D','E','F'
};void Delay(void)
for(j=0;j<1234;j++);
void main(void)
{
VPBDIV = 0x02;
UART0_Init (9600);
PINSEL2 |= 0x0;
UART0_PutC (0xB8);
while (1)
Delay();
Delay();
U0THR = Msg[Row_Data][Col_Data];
Delay();
Delay(); U0THR =
'\r';
}
LCD:
#include <LPC214x.H>
#define RS 0x10000
#define RW 0x20000
#define EN 0x40000
//lcd commands
unsigned char msg[] = {">PS-Primer 2148<"}; //msg unsigned char
msg1[]= {":: LCD Demo! ::"}; //msg1 void delay(unsigned int n)
for(j=0;j<12000;j++)
{;}
LCD4_Convert(data);
void lcd_initialize(void)
int i; for(i=0;i<4;i++)
LCD4_Convert(data);
char i;
i=0;
while(msg[i]!='\0')
delay(5);
lcd_data(msg[i]);i++;
delay(15);
lcd_cmd(0xc0);
delay(15); i=0;
while(msg1[i]!='\0')
delay(5);
lcd_data(msg1[i]);i++;
delay(15);
if(c & 0x80) IOSET0 = 1 << 22; else IOCLR0 = 1 << 22;
if(c & 0x40) IOSET0 = 1 << 21; else IOCLR0 = 1 << 21;
if(c & 0x20) IOSET0 = 1 << 20; else IOCLR0 = 1 << 20;
if(c & 0x10) IOSET0 = 1 << 19; else IOCLR0 = 1 << 19;
if(c & 0x08) IOSET0 = 1 << 22; else IOCLR0 = 1 << 22;
if(c & 0x04) IOSET0 = 1 << 21; else IOCLR0 = 1 << 21;
if(c & 0x02) IOSET0 = 1 << 20; else IOCLR0 = 1 << 20;
if(c & 0x01) IOSET0 = 1 << 19; else IOCLR0 = 1 << 19;
IOSET0 = EN;
//0x4000; //EN
delay(8);
IOCLR0 = EN;
//0x4000; //EN
void main()
PINSEL1 = 0;
OUTPUT:
RESULT:
Thus the interfacing of keyboard and LCD with ARM DEVELOPMENT KIT
microcontroller using embedded C program has been verified successfully.
Ex. No: INTERFACING OF STEPPER MOTOR
Date:
AIM:
To interface and verify the stepper motor with ARM DEVELOPMENT KIT microcontroller
using embedded C program.
APPARATUS REQUIRED:
2 IAR Workbench - 1
3 Flash magic - 1
4 WINXTALK - 1
5 Serial cable - 1
PROCEDURE:
Step 2: To create new project go to project select new micro vision project.
Step 3: select a drive where you would like to create your project.
Step 4: Create a new folder and name it with your project name.
Step 5: Open that project folder and give a name of your project executable
and save it.
Step 6: After saving it will show some window there you select your
microcontroller company i.e NXP from Phillips
Step 8: After selecting chip click on OK then it will display some window
asking to add STARTUP. Select YES.
Step 10: To write your project code select a new from menu bar.
Step 11: It will display some text editor, to save that select SAVE
option from menu bar.
Step 16: It will be added to our target and it shows in the project
window.
Step 17: Now give a right click on target in the project window and select
“Options for Target”
Step 18: It will show some window, in that go to output option and choose
Create Hex option by selecting that box
Step 19: In the same window go to Linker option and choose Use Memory
Layout from Target Dialog by selecting the box, and click OK.
PROGRAM:
STEPPERMOTOR:
#include <lpc21xx.h>
#include <stdio.h>
#define COIL_A 16 // Change here if you want to change theStepper Motor Port!
void delay(int n)
for(j=0;j<0x3FF0;j++)
{;}
}}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< counter-clockwiserotate
function
void motor_ccw(void)
}}
Funciton
void motor_cw(void)
}}
void main(void)
unsigned char i = 0;
as GPIO
as Output Pins
while(1) // Loop
forever..............
clockwise */
i++;
else } }
i = 0; } }
RESULT:
Thus, the interfacing of stepper motor with ARM DEVELOPMENT KIT processor has been
done and executed the temperature value.