Interfacing with seven segment display and LED
using ARM.
(a) Aim: To write and execute a program in Keil Software,interfacing ARM with
SevenSegment Display
Apparatus Required:
Keil Microvision4
Background Theory:
7 segment displays are among the simplest display units to display the numbers and
characters. It is generally used to display numbers and has brighter illumination and
simpler construction than dot matrix display. And because of brighter illumination,
the output can be viewed from larger distance than LCD. As shown in the above
image of a 7-segment display, it consists of 8 LEDs, each LED used to illuminate one
segment of unit and the 8thLED used to illuminate DOT in 7 segment display.
8thLED is used when two or more 7-segment modules are used, for example to
display (0.1). A single module is used to display single digit or character. To display
more than one digit or character, multiple 7-segments are used.
Depending upon connection we classify 7-Segment in two types:
Common Cathode
In this all the Negative terminals (cathode) of all the 8 LEDs are connected
together (see diagram below), named as COM. And all the positive terminals
are left alone or connected to the microcontroller pins. If we use
microcontroller we set logic HIGH to illuminate the particular and set LOW
to turn OFF LED.
Common Anode
In this all the positive terminals (Anodes) of all the 8 LEDs are connected
together, named as COM. And all the negative thermals are left alone or
connected to the microcontroller pins. If we use microcontroller we set logic
LOW to illuminate the particular and set logic High to turn OFF LED.
So depending upon the pin value, a particular segment or line of 7 segment
can be turned on or Off to display desired number or alphabet. For
example to display 0 digit we must set pins ABCDEF as HIGH and only G as
LOW. As ABCDEF LEDs are ON and G is OFF this forms the 0 digit in 7-
segment module. (This is for common cathode, for common anode it is
opposite).
Below table shows the HEX values and corresponding digit according to
LPC2148 pins for common cathode configuration.
The table below shows the circuit connections between 7-Segment module
& LPC2148
Program:
#include<lpc214x.h> //Header file for LPC214x Series microcontrollers
void delay(int ); //Function declaration for delay
int i; //Variable declared as integer
unsigned int a[]={0xf3,0x12,0x163,0x133,0x192,0x1b1,0x1f1,0x13,0x1f3,0x1b3};
//integer array with numbers for display
int main()
{
IO0DIR=IO0DIR|0xffffffff; //Sets direction as output for PORT 0 pins
while(1)
{
for(i=0;i<=9;i++)
{
IO0SET=IO0SET|a[i]; //sets corresponding pins HIGH
delay(9000); //Calls delay function
IO0CLR=IO0CLR|a[i]; //Sets corresponding pins LOW
}
}
return 0;
}
void delay(int k) //Function for making delay
{
int i,j;
for(i=0;i<k;i++)
for(j=0;j<=1000;j++);
}
Result: Thus a program has been written and executed in Keil, interfacing ARM
withseven segment display.
(a) Aim: To write and execute a program in Keil Software,interfacing ARM 7 with
LED and make it blink.
Apparatus Required:
Keil Microvision4
Background Theory:
ARM (Advanced RISC Machines) originally known as Acorn RISC Machine is a
family of reduced instruction set computing (RISC) architecture for computer
processors, configured for various environments. Arm holdings is a British company
who developed this architecture and licensed it to other companies, who design their
own product by using this architecture.
ARM processor is widely found in electronics products such as LED TV, mobile
phones, tablets, multimedia devices, gaming devices etc. Even popular electronics
company like Apple’s mobiles and iPods, Raspberry pi 3 uses ARM architecture and
Arm processor in it. Arm Architecture Examples: ARM7, ARM9, ARM11,
CORTEX.
With more features ARM processor consumes less power.
ARM processor are cheap and that’s why widely used in consumer electronics
Performs one operation at a time and works faster.
Pin Details
Program:
#include <lpc214x.h> //include header files for LPC-214x series
void delay_ms(unsigned int count)
unsigned int j=0,i=0;
for(j=0;j<count;j++) //For loop to create delay
for(i=0;i<3000;i++);
int main()
IO0DIR = (1<<10); //Configure the pin P0.10 as OUTPUT;
while(1) // While loop to execute program continueously
IO0SET = (1<<10) ; // Make the pin P0.10 HIGH (LED ON)
delay_ms(1000);
IO0CLR = (1<<10); // Make the pin P0.10 LOW (LED OFF)
delay_ms(1000);
Result: Thus a program has been written and executed in Keil to interface ARM 7
with LED and make it blink.
Ex No: 2
ASSEMBLY LANGUAGE PROGRAMS USING 8051
Date:
AIM
To write an assembly language program to perform arithmetic operations using
8051 microcontroller.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Keyboard 2a. ADDITION
ALGORITHM
1. Start the program
2. Get the first operand in accumulator
3. Add second operand with first operand in accumulator
4. Move data from accumulator to data pointer
5. Store the result in memory
6. Stop the program
FLOWCHART
PROGRAM
ADDRESS LABEL OPERAND OPCODE COMMENTS
8500 MOV A,#34 74,34 Get 1st operand in A
register
8502 ADD A,#62 24,62 Add operand in A
register
8504 MOV DPTR,#8600 90,45,00 Initialize the data
pointer
8507 MOV X@DPTR,A F0 Store the result in
memory
8508 Here SJMP Here 80 ,FE Stop the program
Execution
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2b. SUBTRACTION
ALGORITHM
1. Start the program
2. Get the first operand in accumulator
3. Subtract the second operand from first operand in accumulator
4. Move data from accumulator to data pointer
5. Store the result in memory
6. Stop the program
PROGRAM
ADDRESS LABEL OPERAND OPCODE COMMENTS
8500 MOV A,#62 74,34 Get 1st operand in A
register
8502 SUBB A,#34 24,62 Subtract operand in A
register
8504 MOV DPTR,#8600 90,45,00 Initialize the data
pointer
8507 MOV X@DPTR,A F0 Store the result in
memory
8508 Here SJMP Here 80 ,FE Stop the program
Execution
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2c. MULTIPLICATION
ALGORITHM
1. Start the program
2. Get the multiplier in A register
3. Get the multiplicand in B register
4. Multiply accumulator content and B register content
5. Store the result in memory
6. Stop the program
FLOWCHART
PROGRAM
ADDRESS LABEL OPCODE OPERAND COMMENTS
8500 MOVA,#06 74,06 Get multiplier in A register
8502 MOV F0,#03 75,0F,03 Get multiplicand in B register
8505 MUL AB A4 Multiply A with B
8506 MOV 90 45 00 Store the result in 4500
DPTR,#8600
8509 MOV X@DPTR,A F0 Move the content to data
pointer
850A INC DPTR A3 Increment data pointer
850B MOVA,F0 E5,F0 Move the content of B register
to accumulator.
850D MOV X@DPTR,A F0 Move the content to data
pointer
850E Here SJMP Here 80,FE Stop the program
Execution
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2d. DIVISION
ALGORITHM
1. Start the program
2. Get the multiplier in A register
3. Get the multiplicand in B register
4. Multiply accumulator content and B register content
5. Store the result in memory
6. Stop the program
PROGRAM
ADDRESS LABEL OPCODE OPERAND COMMENTS
8500 MOV A,#06 74,06 Get Divisor in A register
8502 MOV F0,#03 75,0F,03 Get Dividend in B register
8505 DIV AB A4 Divide A and B
8506 MOV DPTR,#8600 90 45 00 Store the result in 4500
8509 MOV X@DPTR,A F0 Move the content to data
pointer
850A INC DPTR A3 Increment data pointer
850B MOV A,F0 E5,F0 Move the content of B reg. to
A reg.
850D MOV X@DPTR,A F0 Move the content to data
pointer
850E Here SJMP Here 80,FE Stop the program
Execution
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2e) BIT OPERATIONS BY USING 8051
BIT OPERATIONS
SET A BIT
MOV DPTR, #STARTING ADDRESS
MOVX A, @DPTR
SETB 0E5
INC DPTR
MOVX @DPTR, A
L4: SJMP L4 (OFFSET ADDRESS)
LCALL 03
RESET A BIT
MOV DPTR, #STARTING ADDRESS
MOVX A, @DPTR
CLR 0E5
INC DPTR
MOVX @DPTR, A
L4: SJMP L4 (OFFSET ADDRESS)
LCALL 03
COMPLIMENT A BIT
MOV DPTR, #STARTING ADDRESS
MOVX A, @DPTR
CPL 0E5
INC DPTR
MOVX @DPTR, A
L4: SJMP L4 (OFFSET ADDRESS)
LCALL 03
RESULT
Thus the demonstration of basic instructions including conditional jumps,
looping, calling subroutines, stack parameter testing was executed using 8051
microcontroller.
Experiment No. 4 Interfacing DAC and ADC with 8051
Aim:
(a) To execute an Assembly Language Program to convert digital input to analog
output by interfacing Digital to Analog Converter with 8051.
Apparatus Required:
8051 Micro controller Kit
DAC board
Interfacing Chord
Algorithm
1. Initialize the accumulator with 0x80.
2. Set DPTR to 0x4003.
3. Move the value in the accumulator to the memory location pointed by DPTR (0x4003).
Main Loop START:
4. Set the accumulator with 0x00.
5. Set DPTR to 0x4000.
6. Move the value in the accumulator to the memory location pointed by DPTR (0x4000).
7. Call DELAY subroutine.
8. Set the accumulator with 0xFF.
9. Set DPTR to 0x4000.
10. Move the value in the accumulator to the memory location pointed by DPTR
(0x4000).
11. Call DELAY subroutine.
12. Jump to START to repeat the loop.
Delay Subroutine DELAY:
a. Load R1 with 0x10.
Outer Loop LOOP1:
i. Load R0 with 0xFF.
Inner Loop LOOP2:
- Decrement R0.
- If R0 is not zero, jump back to LOOP2.
ii. Decrement R1.
iii. If R1 is not zero, jump back to LOOP1.
b. Return from the subroutine.
Program:
ADDRESS OPCODE MNEMONICS
9100 74 80 MOV A,#80H
9102 90 40 03 MOV DPTR,#4003
9105 F0 MOVX @DPTR,A
9106 74 00 START: MOV A,#00H
9108 90 40 00 MOV DPTR,#4000
910B F0 MOVX @DPTR,A
910C 12 91 1A LCALL DELAY
910F 74 FF MOV A,#0FFH
9111 90 40 00 MOV DPTR,#4000
9114 F0 MOVX @DPTR,A
9115 12 91 1A LCALL DELAY
9118 80 EC SJMP START
911A 79 10 DELAY: MOV R1,#10H
911C 78 FF LOOP1: MOV R0,#0FFH
911E 18 LOOP2: DEC R0
911F B8 00 FC CJNE RO,#00H,LOOP2
9122 19 DEC R1
9123 B9 00 F6 CJNE R1,#00H,LOOP1
9126 22 RET
INFERENCE OF THE RESULT:
Result:
Thus the assembly language program was written to convert digital input to
analog output by interfacing Digital to Analog Converter with 8051.
Aim:
(b) To execute an Assembly Language Program to convert analog input to
digital output by interfacing Analog to Digital Converter with 8051.
Apparatus Required:
8051 Micro controller Kit
ADC board
Interfacing Chord
Algorithm:
1. Initialize A with 0x90.
2. Set DPTR to 0x4003.
3. Write A (0x90) to the external memory at DPTR (0x4003).
4. Set DPTR to 0x4001.
5. Initialize A with 0x01.
6. Write A (0x01) to the external memory at DPTR (0x4001).
7. Initialize A with 0x31.
8. BACK: Write A (0x31) to the external memory at DPTR (0x4001).
9. AND A with 0x01.
10. If the 0th bit of A is not set, jump to BACK.
11. Initialize A with 0x40.
12. Write A (0x40) to the external memory at DPTR (0x4001).
13. Call DELAY subroutine.
14. Set DPTR to 0x4000.
15. Move the value from external memory at DPTR (0x4000) to A.
16. Call the subroutine at address 0x00BB.
DELAY Subroutine:
17. Initialize R0 with 0xFF.
18. LOP: Initialize R1 with 0xFF.
19. LOP1: Decrement R1. If R1 is not zero, jump to LOP1.
20. Decrement R0. If R0 is not zero, jump to LOP.
21. Return from the subroutine.
Program:
ADDRESS OPCODE MNEMONICS
9100 74 90 MOV A,#90
9102 90 40 03 MOV DPTR,#4003
9105 F0 MOVX @DPTR,A
9106 90 40 01 MOV DPTR,#4001
9109 74 01 MOV A,#01
910B F0 MOVX @DPTR,A
910C 74 31 MOV A,#01
910E F0 BACK : MOVX @DPTR,A
910F 74 01 ANL A,#01
9111 F0 JNB 0A,BACK
9112 54 01 MOV A,#40
9114 30 OA FA MOVX @DPTR,A
9117 74 40 LCALL DELAY
9119 F0 MOV DPTR,#4000
911A 12 91 24 MOVX A,@DPTR
911D 90 40 00 LCALL 00BB
9120 E0 DELAY : MOV R0,#FF
9121 12 00 BB LOP: MOV R1,#FF
9124 78 FF LOP1: DJNZ R1,LOP1
9126 79 FF DJNZ RO,LOP
9128 D9 FE RET
912A D8 FA
912C 22
INFERENCE OF THE RESULT:
Result:
Thus the assembly language program was written to convert analog input to digital
output by interfacing Analog to Digital Converter with 8051.
Experiment No.3. Stepper motor control using 8051.
Aim:
To run a stepper motor at different speed in forward and reverse directions.
Apparatus Required:
8051 Micro controller Kit
Stepper motor interfacing kit
Algorithm
[Link] the program
[Link] the counter and DPTR
[Link] the value of micro controller
[Link] till the rotation of stepper motor
[Link] the program
Program:
Memory
Mnemonics
Address
8500 MOV A,#80
8502 MOV DPTR,#4003
8505 MOVX @DPTR,A
8506 START: MOV DPTR,#8600
8509 MOV R1,82
850B MOV R2,83
850D MOV R0,#04
850F REP: MOVX A,@DPTR
8510 MOV DPTR,#4000
8513 MOVX @DPTR,A
8514 LCALL DELY
8517 INC R1
8518 MOV 82,R1
851A MOV 83,R2
851C DJNZ R0,REP
851E SJMP START
8520 DELY: MOV R7,#03
8522 LOOP3: MOVR6,#0A
8524 LOOP2: MOV R3,#FF
8526 LOOP1: DJNZ R3,LOOP1
8528 DJNZ R6,LOOP2
852A DJNZ R7,LOOP3
852C RET
INFERENCE OF THE RESULT:
Result:
Thus the assembly language program was written to rotate a stepper motor
in forward and reverse directions and executed by using 8051 microcontroller &
stepper motor interfacing kit.
Ex No: 1
ASSEMBLY LANGUAGE PROGRAMS USING 8086
AIM
To write the assembly language program to perform arithmetic operation using
8086 microprocessor
APPARATUS REQUIRED
8086 microprocessor Kit
Keyboard
1 a) ADDITION OF TWO 32-BIT NUMBERS USING
8086 ALGORITHM
Addition
1. Start the program
2. Load the LSB and MSB of 1st number to AX and BX register respectively
3. Load the LSB and MSB of 2nd number to CX and DX register respectively
4. Initialize the carry as zero
5. Add the LSB of both the numbers
6. Add the MSB of both the numbers with previous carry
7. Check the carry flag, if set then increment carry by 1
8. Store the sum in memory location
9. Halt the program.
FLOW CHART
PROGRAM
ADDRESS LABEL MNEMONICS COMMENTS
1000 MOV AX,[2000] Move LSB of 1st number to AX register.
1003 MOV BX,[2002] Move MSB of 1st number to BX register.
1007 MOV CX,[2004] Move LSB of 2nd number to CX register.
100B MOV DX,[2006] Move MSB of 2nd number to DX register.
100F MOVDI,0000 Initialize Carry to zero
1012 ADD AX,CX Add the LSB of both the numbers
1014 ADC BX,DX Add the MSB of both the numbers with previous carry
1016 JNC 101B If Carry=0, go to LOOP
1018 MOVDI,0001 Increment Carry by 1
101B LOOP MOV[2008],AX Store the LSB of sum.
101E MOV[200A],BX Store the MSB of sum.
1022 MOV[200C],DI
1026 HLT Stop the program.
EXECUTION
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
[Link]:1b SUBTRACTION OF TWO 32-BIT NUMBERS USING
8086
ALGORITHM
Subtraction
1. Start the program
2. Load the LSB and MSB of 1st number to AX and BX register respectively
3. Load the LSB and MSB of 2nd number to CX and DX register respectively
4. Initialize the carry as zero
5. Subtract the LSB of both the numbers
6. Subtract the MSB of both the numbers with previous borrow
7. Store the sum in memory location
8. Halt the program.
FLOWCHART
PROGRAM
ADDRESS MNEMONICS COMMENTS
1000 MOV AX,[2100] Move LSB of 1st number to AX register.
1003 MOV BX,[2102] Move MSB of 1st number to BX register.
1007 MOV CX,[2104] Move LSB of 2nd number to CX register.
100B MOV DX,[2106] Move MSB of 2nd number to DX register.
100F SUB AX,CX Subtract the LSB of both the numbers
Subtract the MSB of both numbers with previous
1011 SBB BX,DX
borrow
1013 MOV[2108],AX Store the LSB of result.
1016 MOV[210A],BX Store the MSB of result.
101A HLT Stop the program.
EXECUTION
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
[Link]:1c MULTIPLICATION OF TWO 16-BIT NUMBERS
USING 8086
ALGORITHM
Multiplication
1. Start the program
2. Move the 1st 16-bit data to AX register
3. Move the 2nd 16- bit data to BX register
4. Multiply both the numbers
5. Store the result from the Accumulator to the specified address
6. Move the carry from DX register to the specified address
7. Stop the program
FLOWCHART
PROGRAM
ADDRESS MNEMONICS COMMENTS
2000 MOV AX,[1100] Move the 1st data from the address to AX register.
2003 MOV BX,[1102] Move the 2nd data from the address to BX register.
Multiply the contents of BX register with the
2007 MUL BX
Accumulator i.e., AX register.
Move the result from Accumulator register to the
2009 MOV [1200],AX
address
200C MOV [1202],DX Move the Carry from DX register to the address
2010 HLT Stop the program.
EXECUTION
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
[Link]:1d DIVISION OF TWO 16-BIT NUMBERS
USING 8086
Division
ALGORITHM
1. Start the program
2. Initialize DX register for storing the reminder
3. Move the 1st 16-bit data i.e dividend to AX register
4. Move the 2nd 16-bit data i.e divisor to BX register
5. Divide both the numbers.
6. Store the result from the accumulator to the specified address.
7. Move the remainder from DX register to the specified address.
8. Stop the Program
FLOWCHART
PROGRAM
ADDRESS MNEMONICS COMMENTS
2000 MOV DX,[1100] Initialize the DX register for storing the remainder.
2004 MOV AX,[1102] Move the dividend from the address to AX register.
2007 MOV BX,[1104] Move the divisor from the address to BX register.
Divide the contents of BX register with the
200B DIV BX
Accumulator i.e., AX register.
Move the quotient from Accumulator register to the
200D MOV [1200],AX
address
2010 MOV [1202],DX Move the remainder from DX register to the address
2014 HLT Stop the program.
EXECUTION
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
RESULT
Thus the arithmetic operations are performed using 8086 microprocessor and
the result is stored in memory.
Ex No.5 Sensor Interfacing using 8051 Micro controller
Objective: To measure the temperature and store the digital value in memory using 8051 microcontroller.
Apparatus:
● 8051 kit
● ADC board
● LM35 (temperature sensor)
Theory:
The LM35 series sensors are precision integrated-circuit temperature sensors, whose output voltage is
linearly proportional to the Centigrade temperature. It gives 10mV of output voltage for every 10C. The LM35
does not require any external calibration or trimming to provide typical accuracies of ±¼°C at room temperature
and ±¾°C over a full -55 to +150°C temperature range. The LM35's low output impedance, linear output, and
precise inherent make interfacing to readout or control circuitry especially easy. It can be used with single
power supplies, or with dual supplies. As it draws only 60 µA from its supply, it has very low self- heating, less
than 0.1°C in still air. The LM35 is rated to operate over a -55° to +150°C temperature range. The LM35 IC
sensor is available at a Low cost .LM35 is a three terminal IC with, Vcc, Ground & Vout
The LM 35 IC gives a 10mV analog output voltage for every degree Celsius change in temperature. The
Output of the temperature sensor is analog in nature so we need an analog to digital converter for converting
the analog input to its equivalent binary output.
Since the output of LM35 is analog voltage, it should be converted into digital before it is applied to a
microcontroller port pin.
Circuit:
Program:
MOV P1, #0xFF ; Configure Port 1 as input (data lines from ADC)
MOV P2, #0x00 ; Configure Port 2 as output (control signals to ADC)
START:
CLR P2.3 ; Set WR (P2.3) low to start conversion
NOP ; Small delay
SETB P2.3 ; Set WR (P2.3) high after starting conversion
WAIT_INTR:
JB P2.4, WAIT_INTR; Wait until INTR (P2.4) goes low
; Read ADC data
CLR P2.1 ; Set CS (P2.1) low to enable ADC
CLR P2.2 ; Set RD (P2.2) low to read data
MOV A, P1 ; Read data from ADC to accumulator
MOV TEMP_LOW, A; Store low byte of temperature reading
SETB P2.2 ; Set RD (P2.2) high after reading data
MOV A, TEMP_LOW
ADD A, A
MOV TEMP_HIGH, A; Store high byte of temperature (in °C)
SJMP START ; Repeat the process
END
Result:
Thus, the temperature is measured and stored in memory using 8051.