MP&MC Lab Obse Student
MP&MC Lab Obse Student
Department of ECE
Lab observation
1
2
3
4
5
6
Contents
Page Internal Faculty
S.No. Date Name of the Experiments
No. Marks Sign.
7
FLOWCHART
ADDITION SUBTRACTION
START START
GET FIRST
GET FIRST OPERAND
OPERAND TO A
YES
A=A+B
IS THERE
ANY CY
YES NO COUNTER =
IS THERE COUNTER + 1
ANY
CARRY
STOP
8
EXPT NO:1(a) 8086 PROGRAMMING DATE:
AIM:
To write an Assembly Language Program (ALP) for performing the addition and
subtraction operation of two byte numbers.
APPARATUS REQUIRED:
8086 kit, Power Chord
ALGORITHM:
(i) 16-bit addition
a. Initialize the MSBs of sum to 0
b. Get the first number.
c. Add the second number to the first number.
d. If there is any carry, increment MSBs of sum by 1.
e. Store LSBs of sum.
f. Store MSBs of sum.
g.
(ii) 16-bit subtraction
a. Initialize the MSBs of difference to 0
b. Get the first number
c. Subtract the second number from the first number.
d. If there is any borrow, increment MSBs of difference by 1.
e. Store LSBs of difference
f. Store MSBs of difference.
PROGRAM:
16-BIT ADDITION:
9
1019 F4 HLT Stop the program
ADDITION
ADDRESS DATA
1200
1201
INPUT
1202
1203
OUTPUT 1204
(SUM) 1205
OUTPUT 1206
(CARRY) 1207
SUBTRACTION
ADDRESS DATA
1200
1201
INPUT
1202
1203
OUTPUT 1204
(Difference) 1205
OUTPUT 1206
(Borrow) 1207
10
16-BIT SUBTRACTION:
RESULT:
Thus addition & subtraction of two byte numbers are performed and the result is stored.
11
FLOWCHART
MULTIPLICATION DIVISION
Start
Start
QUOTIENT = 0
REGISTER=00
DIVIDEND =
DIVIDEND-DIVISOR
REGISTER =
REGISTER +
MULTIPLICAND
QUOTIENT = QUOTIENT+1
Multiplier=MU
LTIPLIER – 1
IS
NO DIVIDEN
D<
DIVISOR
NO IS
?
MULTIPLIER
=0?
YES
STOP STOP
12
EXPT NO:1(b) 8086 PROGRAMMING DATE:
AIM:
To write an Assembly Language Program (ALP) for performing the multiplication and
division operation of 16-bit numbers.
APPARATUS REQUIRED:
ALGORITHM:
PROGRAM:
MULTIPLICATION:
13
MULTIPLICATION:
ADDRESS DATA
1200
1201
INPUT
1202
1203
OUTPUT 1206
(SUM) 1207
OUTPUT 1208
(CARRY) 1209
DIVISON:
ADDRESS DATA
1200
1201
INPUT
1202
1203
OUTPUT 1206
(Quotient) 1207
OUTPUT 1208
(Remainder) 1209
14
DIVISION:
RESULT:.
Thus multiplication & division of two byte numbers are performed and the result is stored.
15
Flowchart of Ascending (8086):
16
EXPT NO:2(a) 8086 PROGRAMMING DATE:
SORTING
AIM:
To write an assembly language program for the sorting in ascending and descending order, using
8086
APPARATUS REQUIRED:
THEORY:
The Bubble-Sort technique is used to sort the numbers in either ascending order or
descending order. The numbers to be sorted is stored in the memory as a array with the first
location containing the count of the data in the array. The sorted numbers are stored back again
in the same source location of the array.
17
Flowchart of Descending (8086):
18
PROGRAM FOR ASCENDING ORDER:
DESCENDING ORDER:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
1100 1100
1102 1102
1104 1104
1106 1106
1108 1108
110A 110A
110C 110C
110E 110E
20
RESULT:
Thus the assembly language programs for sorting in ascending & descending order was
executed and verified
21
START
NO
YES
Check for
ZF=1
Move DI to BX
STOP
INPUT:
0500 =
0501 =
0502 =
0503 = 0504 = 0800 =
RESULT:
0750=
22
SEARCHING A STRING
AIM:
To scan for a given byte in the string and find the relative address of the byte from the
starting location of the string.
APPARATUS REQUIRED:
ALGORITHM:
a. Initialize the extra segment .(ES)
b. Initialize the start of string in the ES. (DI)
c. Move the number of elements in the string in CX register.
d. Move the byte to be searched in the AL register.
e. Scan for the byte in ES. If the byte is found ZF=0, move the address pointed by ES:DI to
BL.
RESULT:
Thus a given byte or word in a string of a particular length in the extra segment
(destination) is found .
FLOWCHART
23
START
NO
IS EOC =
1?
YES
STOP
24
EXPT NO: 3(a) 8086 INTERFACING DATE:
INTERFACING ANALOG TO DIGITAL CONVERTER
AIM:
To write an assembly language program to convert an analog signal into a digital signal
using an ADC interfacing.
APPARATUS REQUIRED:
THEORY:
An ADC usually has two additional control lines: the SOC input to tell the ADC when to
start the conversion and the EOC output to announce when the conversion is complete. The
following program initiates the conversion process, checks the EOC pin of ADC 0809 as to
whether the conversion is over and then inputs the data to the processor. It also instructs the
processor to store the converted digital data at RAM location.
ALGORITHM:
25
26
PROGRAM TABLE
RESULT:
Thus the ADC was interfaced with 8086 and the given analog inputs were converted into its
digital equivalent.
27
FLOWCHART:
MEASUREMENT OF ANALOG VOLTAGE SQUARE WAVE FORM
START START
TRIANGULAR WAVEFORM
STOP
START
SAWTOOTH WAVEFORM
INITIALIZE
START
ACCUMULATOR
INCREMENT
SEND ACCUMULATOR ACCUMULATOR
CONTENT
INCREMENT
CONTENT TO DAC
ACCUMULATOR YES
CONTENT IS ACC
NO YES FF
NO
IS
ACC DECREMENT
FF ACCUMULATOR CONTENT
SEND ACCUMULATOR
CONTENT TO DAC
IS ACC
28 00
YES NO
EXPT NO: 3(b) 8086 INTERFACING DATE:
INTERFACING DIGITAL – TO – ANALOG CONVERTER
AIM :
1. To write an assembly language program for digital to analog conversion
2. To convert digital inputs into analog outputs & To generate different waveforms
APPARATUS REQUIRED:
THEORY:
Since DAC 0800 is an 8 bit DAC and the output voltage variation is between –5v and
+5v. The output voltage varies in steps of 10/256 = 0.04 (approximately). The digital data input
and the corresponding output voltages are presented in the table. The basic idea behind the
generation of waveforms is the continuous generation of analog output of DAC. With 00 (Hex)
as input to DAC2 the analog output is –5v. Similarly with FF H as input, the output is +5v.
Outputting digital data 00 and FF at regular intervals, to DAC2, results in a square wave of
amplitude 5v.Output digital data from 00 to FF in constant steps of 01 to DAC2. Repeat this
sequence again and again. As a result a saw-tooth wave will be generated at DAC2 output.
Output digital data from 00 to FF in constant steps of 01 to DAC2. Output digital data from FF to
00 in constant steps of 01 to DAC2. Repeat this sequence again and again. As a result a
triangular wave will be generated at DAC2 output.
ALGORITHM:
Waveform generation:
Square Waveform:
(i) Send low value (00) to the DAC.
(ii) Introduce suitable delay.
(iii) Send high value to DAC.
(iv) Introduce delay.
(v) Repeat the above procedure.
Saw-tooth waveform:
29
WAVEFORM GENERATION:
Saw-tooth waveform
Triangular waveform
MODEL GRAPH:
Triangular waveform
30
Triangular waveform:
(i) Load the low value (00) in accumulator.
(ii) Send this accumulator content to DAC.
(iii) Increment the accumulator.
(iv) Repeat step 2 and 3 until the accumulator reaches FF, decrement the
accumulator and send the accumulator contents to DAC.
(v) Decrementing and sending the accumulator contents to DAC.
(vi) The above procedure is repeated from step (i)
PROGRAM:
Square Wave:
31
32
Triangular Wave:
RESULT:
Thus the DAC was interfaced with 8085 and different waveforms have been generated.
33
FLOWCHART
STOP
34
EXP. NO: 4 INTERFACING PROGRAMMABLE PERIPHERAL
INTERFACE 8255 DATE:
AIM:
To write ALP by interfacing 8255 with 8086 in mode 0, mode 1 and mode 2
APPARATUS REQUIRED:
ALGORITHM:
Bit set/reset, applicable to PC only. One bit is S/R at a time. Control word:
D7 D6 D5 D4 D3 D2 D1 D0
0 (0=BSR) X X X B2 B1 B0 S/R (1=S,0=R)
35
I/O mode
36
D7 D6 D5 D4 D3 D2 D1 D0
1 (1=I/O) GA mode select PA PCU GB mode select PB PCL
D6, D5: GA mode select:
o 00 = mode0
o 01 = mode1
o 1X = mode2
D4(PA), D3(PCU): 1=input 0=output
D2: GB mode select: 0=mode0, 1=mode1
D1(PB), D0(PCL): 1=input 0=output
PROGRAM:
Transmitter
37
Receiver
38
MEMORYADDRESS OPCODES MNEMONICS
Result:
The programs for interfacing 8255 with 8086 are executed & the output is obtained for
modes 0, 1 & 2.
FLOWCHART:
39
SET UP
POINTER
INITIALIZE THE COUNTER
DELAY
LOOK-UP TABLE:
1200 98 68 7C C8
1204 FF 1C 29 FF
AIM :
To display the rolling message “HELP US “in the display.
APPARATUS REQUIRED:
8086 Microprocessor kit, Power supply, interfacing board.
ALGORITHM :
Display of rolling message “ HELP US “
1. Initialize the counter
2. Set 8279 for 8 digit character display, right entry
3. Set 8279 for clearing the display
4. Write the command to display
5. Load the character into accumulator and display it
6. Introduce the delay
7. Repeat from step 1.
0 0 0 1 0 0 0 0
0 0 0 D D K K K
DD
00- 8Bit character display left entry
01- 16Bit character display left entry
10- 8Bit character display right entry
11- 16Bit character display right entry
KKK- Key Board Mode
000-2Key lockout.
1 1 0 1 1 1 0 0
1 1 0 CD CD CD CF CA
42
1 0 0
AI A A A A
1207H 1 1 1 1 1 1 1 1 FF
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7C60012 START : MOV SI,1200H Initialize array
1004 C7C10F00 MOV CX,000FH Initialize array size
1008 C6C010 Store the control word for
MOV AL,10
display mode
100B E6C2 OUT C2,AL Send through output port
100D C6C00C Store the control word to
MOV AL,0CC
clear display
1010 E6C2 OUT C2,AL Send through output port
1012 C6C090 Store the control word to
MOV AL,90
write display
1015 E6C2 OUT C2,AL Send through output port
1017 8A04 L1 : MOV AL,[SI] Get the first data
1019 E6C0 OUT C0,AL Send through output port
101B E8C0F0 CALL DELAY Give delay
101E 46 INC SI Go & get next data
101F E2F6 Loop until all the data’s
LOOP L1
have been taken
1021 E9DCFF JMP START Go to starting location
1024 C7C2FFA0 DELAY : MOV DX,0A0FFH Store 16bit count value
1028 4A LOOP1 : DEC DX Decrement count value
1029 75FD Loop until count values
JNZ LOOP1
becomes zero
102B1 C3 RET Return to main program
43
44
START
INITIALIZE ACCUMULATOR
WITH MODE SET WORD
45
TRIGGER THE COUNT
STOP
CONTROL WORD FORMAT:
D7 D6 D5 D4 D3 D2 D1 D0
SC1 SC0 RL1 RL0 M2 M1 M0 BCD Mode 2 = 34 H
0 0 1 1 0 1 0 0
0 0 1 1 0 1 1 0 Mode 3 = 36 H
0 0 CHANNEL 0 0 0 LATCH
0 1 CHANNEL 1 0 1 LSB
1 0 CHANNEL 2 1 0 MSB
1 1 ----- 1 1 LSB FIRST, MSB NEXT
BCD --0 –BINARY COUNTER 1 --BCD COUNTER
M2 M1 M0 MODE
0 0 0 MODE 0
0 0 1 MODE 1
0 1 0 MODE 2
0 1 1 MODE 3
1 0 0 MODE 4
1 0 1 MODE 5
46
AIM :
To study different modes of operation of programmable timer 8253
APPARATUS REQUIRED:
8086 kit, Power Chord, 8253 interfacing kit, CRO
THEORY:
The main features of the timer are,
i. Three independent 16-bit counters
ii. Input clock from DC to 2 MHz
iii. Programmable counter modes
iv. Count binary or BCD
The control signals with which the 8253 interfaces with the CPU are CS, RD, WR, A1,
A2.The basic operations performed by 8253 are determined by these control signals. It has six
different modes of operation, viz, mode 0 to mode 5.
ALGORITHM:
Mode 2-
1. Initialize channel 0 in mode 2
2. Initialize the LSB of the count.
3. Initialize the MSB of the count.
4. Trigger the count
5. Read the corresponding output in CRO.
Mode 3-
1. Initialize channel 0 in mode 3
2. Initialize the LSB of the count.
3. Initialize the MSB of the count.
4. Trigger the count
5. Read the corresponding output in CRO.
MODEL GRAPH:
47
RATE GENERATOR:
48
MODE 2 – RATE GENERATOR:
49
50
RESULT:
Thus an ALP for rate generator and square wave generator are written and executed.
51
EX.NO. 5(c) INTERFACING PROGRAMMABLE INTERRUPT CONTROLLER - 8259
52
DATE:
AIM :
To interface programmable interrupt controller with 8086.
APPARATUS REQUIRED:
8086 kit, Power Chord, 8259 interfacing kit
ALGORITHM:
Initialize 8259 with the following specifications:
1. ICW4 needed,
2. single 8259,
3. Interval of 4,
4. Edge triggered mode,
5. A7, A6 , A5 = 0 0 0
6. Initialize to type 8 Interrupt
7. 8086 mode
8. Normal EOI
9. Non- buffered mode
10. Not special fully nested mode
11. Mask all Interrupts except IRQ 0
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
2000 C6C017 Store the control word in
MOV AL, 17
accumulator
2003 E6C0 OUT C0, AL Send through output port
2005 C6C008 Store the control word in
MOV AL, 08
accumulator
2008 E6C2 OUT C2,AL Send through output port
200A C6C001 Store the control word in
MOV AL, 01
accumulator
200D E6C2 OUT C2,AL Send through output port
200F C6C0FF Store the control word in
MOV AL,0FE
accumulator
2012 E6C2 OUT C2,AL Send through output port
2014 FB STI Set Interrupt
2015 E9FDFF HERE JMP HERE End of the program
53
INTERRUPT SERVICE ROUTINE:
54
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1200 C6C020 Store the control word in
MOV AL, 20
accumulator
1203 E6C0 OUT C0, AL Send through output port
1205 CD02 INT 2 Call interrupt 2
INTERRUPT VECTOR:
0000:0020 00
0000:0021 12
0000:0022 00
0000:0023 00
RESULT:
Thus the program for interfacing 8259 with 8086 are executed & the output is obtained
55
56
Ex.No:6 SERIAL COMMUNICATION BETWEEN TWO MP KITS USING 8251.
DATE:
AIM:
To write an assembly language program in 8086 to transmit & receive data between serial
ports of 8086 using RS232 cable.
APPARATUS REQUIRED:
8086 kit, Power Chord, RS-232 Cable.
PROGRAM:
Transmitter program:
FLOW CHART:
START
57
Check TX/RX Ready
No
Is it High
Yes
STOP
Receiver program:
58
ADDRESS LABEL MNEMONICS OPERAND OPCODE
1000 MOV SI,1500H C7C60015
1004 MOV AL,36H C6C036
1007 OUT 16H,AL E616
1009 MOV AL,40H C6C040
100C OUT 10H,AL E610
100E MOV AL,01H C6C001
1011 OUT 10H,AL E610
1013 RELOAD MOV CL,05H C6C105
1016 CHECK IN AL,0AH E40A
1018 AND AL,04H 80E002
101B JZ CHECK 74F9
101D IN AL,08 E408
101F MOV [SI],AL 8804
1021 INC SI 46
1022 CMP AL,3FH 80F83F
1025 JNZ RELOAD 75EC
1027 DEC CL FEC9
1029 JNZ CHECK 7BEB
102B INT 02 CD02
102D INT 02 CD02
RESULT:
Thus the assembly language program in 8086 to transmit & receive data between parallel
ports of 8086 was written & the output was obtained
59
60
EXP.NO: 7 STEPPER MOTOR INTERFACING DATE:
AIM:
To write an assembly language program in 8086 to rotate the motor at different speeds.
APPARATUS REQUIRED:
8086 kit, Stepper Motor, Stepper Motor Interface board
THEORY:
A motor in which the rotor is able to assume only discrete stationary angular position
is a stepper motor. The rotary motion occurs in a stepwise manner from one equilibrium position
to the next.Two-phase scheme: Any two adjacent stator windings are energized. There are two
magnetic fields active in quadrature and none of the rotor pole faces can be in direct alignment
with the stator poles. A partial but symmetric alignment of the rotor poles is of course possible.
ALGORITHM:
PROGRAM:
61
FLOWCHART:
START
DELAY
DECREMENT COUNTER
YES
NO IS B = 0 ?
MEMORY A1 A2 B1 B2 HEX
LOCATION CODE
4500 1 0 0 0 09 H
4501 0 1 0 1 05 H
4502 0 1 1 0 06 H
4503 1 0 1 0 0A H
62
RESULT:
Thus the assembly language program for rotating stepper motor in both clockwise and
anticlockwise directions is written and verified.
63
FLOW CHART:
ADDITION
START
Clear PSW
Select Register
Bank
Load A and R 0
with 8- bit datas
Add A & R 0
STOP
SUBTRACTION
START
Clear PSW
Select Register
Bank
Load A and R 0
with 8- bit datas
Subtract A & R 0
STOP
64
EXPT NO: 8(a) ARITHMETIC OPERATION USING 8051 DATE:
AIM:
To perform arithmetic operations using 8051 microcontroller.
APPARATUS REQUIRED:
ALGORITHM:
Addition:
1) Move the data 1(05) to accumulator.
2) Add the data 2(03) with accumulator.
3) Move the content 4500 to DPTR.
4) Move the accumulator value to DPTR
5) Short jump to HERE(4108).
Subtraction:
1) Move the data 1(06) to accumulator.
2) Add the data 2(04) with accumulator.
3) Move the content 4500 to DPTR.
4) Move the accumulator value to DPTR
5) Short jump to HERE(4108).
Multiplication:
1) Move the data 1(05) to accumulator.
2) Move the data 2(08) to B register.
3) Multiply the content of A & B.
4) Move the content 4500 to DPTR.
5) Move the accumulator value to DPTR.
6) Increment DPTR by 1.
7) Move the content of B to A.
8) Move the accumulator value to DPTR.
9) Short jump to HERE(410E).
Division:
1) Move the data 1(06) to accumulator.
2) Move the data 2(03) to B register.
3) Divide the content of A by B.
4) Move the content 4500 to DPTR.
5) Move the accumulator value to DPTR.
6) Increment DPTR by 1.
7) Move the content of B to A.
8) Move the accumulator value to DPTR.
9) Short jump to HERE(410E).
65
MULTIPLICATION
START
Clear PSW
Select Register
Bank
Load A and B
with 8- bit datas
Multiply A & B
STOP
DIVISION
START
Clear PSW
Select Register
Bank
Load A and B
with 8- bit datas
Divide A & B
STOP
66
PROGRAM:
8 bit subtraction:
ADDRESS LABEL MNEMONICS OPERAND OPCODE
4100 MOV A, # 06 74,06
4102 SUBB A, #04 94,04
4104 MOV DPTR, # 4500 90,45,00
4107 MOVX @ DPTR, A F0
4108 HERE SJMP HERE 80,08,41
8 bit multiplication:
ADDRESS LABEL MNEMONICS OPERAND OPCODE
4100 MOV A, # 05 74,05
4102 MOV B, # 08 75, 00,F0,03
4105 MUL AB A4
4106 MOV DPTR, # 4500 90,45,00
4109 MOVX @ DPTR, A F0
410A INC DPTR A3
410B MOV A,B E5,F0
410D MOVX @ DPTR,A F0
410E HERE SJMP HERE 80,0E,41
8 bit division:
ADDRESS LABEL MNEMONICS OPERAND OPCODE
4100 MOV A, # 06 74,06
4102 MOV B, #03 74,F0,03
4105 DIV AB 84
4106 MOV DPTR, # 4500 90,45,00
4109 MOVX @ DPTR, A F0
410A INC DPTR A3
410B MOV A,B E5,F0
410D MOVX @ DPTR, A F0
410E HERE SJMP HERE 80,0E,41
67
ADDTION:
OUTPUT
MEMORY LOCATION DATA
4500
DATA 1
DATA 2
SUBRACTION:
OUTPUT
MEMORY LOCATION DATA
4500
DATA 1
DATA 2
MULTIPLICATION:
INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA
4200 4500
4201
DIVISION:
INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA
4200 (dividend) 4502 (remainder)
68
RESULT:
Thus the arithmetic operations using 8051 microcontroller has been performed and output
was obtained.
69
FLOWCHART:
AND
START
STOP
XOR
START
STOP
NOT
START
STOP
70
EXP. NO: 8(b) LOGICAL OPERATIONS USING 8051 DATE:
AIM:
To perform logical operations using 8051 microcontroller.
APPARATUS REQUIRED:
8051 microcontroller kit, Power Chord
ALGORITHM:
AND:
1) Move data 1 to accumulator.
2) AND data 2 with accumulator.
3) Move the data 4500 to DPTR.
4) Move the accumulator value to DPTR.
5) Short jump to HERE (4108).
XOR:
1) Move data 1 to accumulator.
2) XOR data 2 with accumulator.
3) Move the data 4500 to DPTR.
4) Move the accumulator value to DPTR.
5) Short jump to HERE (4108).
NOT:
1) Move data 1 to accumulator.
2) Not the content of accumulator.
3) Move the data 4500 to DPTR.
4) Move the accumulator value to DPTR.
5) Short jump to HERE (4107).
71
AND:
OUTPUT
MEMORY LOCATION DATA
4500
DATA 1
DATA 2
XOR:
OUTPUT
MEMORY LOCATION DATA
4500
DATA 1
DATA 2
NOT:
OUTPUT
MEMORY LOCATION DATA
4500
DATA
72
PROGRAM:
AND:
XOR:
NOT:
RESULT:
73
Thus logical operations have been performed using 8051 microcontroller and output was
obtained.
FLOWCHART:
START
Increment A by 1
STOP
OUTPUT
MEMORY LOCATION DATA
4200
DATA
74
Ex.No: 8(c) BIT MANIPULATION INSTRUCTIONS USING 8051
DATE:
AIM:
To write an assembly language program for performing 1’s & 2’s complement operations
using 8051.
APPARATUS REQUIRED:
8051 microcontroller kit, Power Chord
PROGRAM:
ALGORITHM:
RESULT:
75
Thus the assembly language program for 1’s & 2’s complement operations using 8051
was written & the output was obtained.
INPUT:
1500 = 12
1501 = 10
1502 = 06
OUTPUT :
06:10:12
INPUT :
1500 00
1501 00
1502 00
OUTPUT:
00:00:00
76
EX.NO. 9 COMMUNICATION BETWEEN 8051 MICROCONTROLLER
KIT & PC
DATE :
AIM:
To write an ALP to communicate between 8051 microcontroller kit & PC
APPARATUS REQUIRED:
8051 microcontroller kit, PC
RESULT:
77
Thus the communication between 8051 microcontroller kit and PC is done.
78
EX.NO. 10 INTERFACING SWITCH AND LED WITH ARDUINO DATE :
AIM:
To Connect and operating LED connected to the digital outputs of an Arduino.
APPARATUS REQUIRED:
PROGRAM:
3. Make sure you select the right board (see below screen-shot)
79
80
Part 2: Compiling and Uploading file to the Arduino
1. Once you see your Arduino board is connected to your computer. Go to the
File menu -> Examples -> 01.Basics -> Blink.
81
82
2. This should open up a new window that has a tab labeled Blink. See below screen-shot
for description.
3. Then click on the Sketch menu and check for any typos / errors using verify button and
Compile to the machine language if the verification is successful.
83
84
4. If the above process is successful, you should see the message in the status
bar showing that the compilation is successful.
5. Now upload your program to the Arduino by clicking upload button in the
Sketch menu.
6. You might face some issues from step 3-5 if you have not selected a correct
board/serial port. So please make sure you went through the part 1
carefully.
1. In the above Blink code you see bunch of lines performing certain operations. In
our case, turning on and off an LED connected to the Digital pin 13.
2. Most Arduinos have an on-board LED that is attached to digital pin 13. So, you
must see the LED on your board starting to blink. (In some cases, the boards are
pre-installed with the program. So the LED starts to blink once you have powered
the Arduino )
In the code you can see that the OUTPUT is being taken from the digital pin 13. We can
change the output of the board by just changing the output pin numbers, i.e., see what
happens if you replace 13 with 12. (You have to upload every time to see the changes)
85
86
3. Before uploading your new code to the Arduino we have to make sure that LED is
connected to the Digital pin 12, if there is nothing connected we don’t have a way
to see our result. Please follow the below schematic for connecting the LED to the
digital pins on the Arduino board. A series resistor is mandatory for the circuit, it
prevents the LED from burning out.
4. Now, you have a blinking LED controlled using an Arduino. Now, we can change
the LED turn on and off times by editing the time in the software.
RESULT:
Thus the assembly program interfacing switch and LED with Arduino was executed.
The output was verified in the Arduino kit.
87
88
EX.NO. 11 INTERRUPT PROGRAMMING USING PIC
DATE :
AIM:
To write an assembly program for interrupt and verify the output in the PIC16F877.
APPARATUS REQUIRED:
PROCEDURE:
THEORY:
Interrupt is the one of the most powerful feature in embedded applications. Almost all
the real time applications are implemented using Interrupts. So what is an Interrupt…?? As
the name suggests Interrupts are a special event that requires immediate attention, it stops a
microcontroller/microprocessor from the running task and to serve a special task known as
Interrupt Service Routine (ISR) or Interrupt Handler. Suppose you are at home, taking coffee.
Suddenly your mobile phone rings. You stop taking coffee and answer the call. When you
have finished the conversation, you will go back to take coffee. This process is similar to ISR
execution. You can think the main service routine as taking coffee and the ringing of mobile
phone is causes interrupt in taking coffee. This initiates your mobile phone conversation
which is similar to executing ISR. When the mobile conversation is ended you will go back
to the main service routine of taking coffee. Consider a MP3 player which builds around
microcontroller. It contains push button switches to select song, control volume etc. The
microcontroller should be programmed to convert the data stored in MP3 files to electrical
signal and to change controls according to the status of push button switches. Consider this
application without using interrupt; the programmer wants to continuously do the following
tasks.
Read the status of push button switches and change controls accordingly
89
90
This process of continuous monitoring is known as POLLING. This is not an efficient
way of programming as it consumes all its processing time for monitoring. Consider if this
problem is addressed using Interrupts. The microcontroller wants to respond only when
an interrupt occurs. Here is an analogy to understand the difference better. The method of
polling is similar to a salesperson, which goes door-to-door to requesting to buy his product
or service. This is similar to a microcontroller continuously monitoring the status of all
devices attached to it.
Hardware and Software Interrupts: PIC Microcontroller consists of both Hardware and
Software Interrupts. If the interrupts are generated by external hardware at certain pins of
microcontroller, or by inbuilt devices like timer, they are called Hardware Interrupts. While
Software interrupts are generated by a piece of code in the program. Also known as External
and Internal Interrupts.
PROGRAM:
LIST P=P16F877
INCLUDE "P16F877.INC"
;CBLOCK 0X20
;SCALER
;TEMP1
;TEMP
;ENDC
ORG 0X00
BCF STATUS,RP1
BSF STATUS,RP0 ;SELECT BANK1
MOVLW B'00010000'
MOVWF TRISB ;RB4 INPUT PORT
MOVLW 0X7F
MOVWF OPTION_REG
CLRF TRISA
CLRF TRISE
BCF STATUS,RP0
CLRF PORTA
CLRF PORTE
END
RESULT:
Thus the assembly program for interrupt was written and executed. The output was
verified in the PIC16F877 kit.
93
94
EX.NO. 12 USART PROGRAMMING USING PIC DATE :
AIM:
APPARATUS REQUIRED:
PROCEDURE:
THEORY:
95
96
PROGRAM:
LIST P=P16F877
INCLUDE "P16F877.INC"
ERRORLEVEL -302
CBLOCK H'20'
DATA1
ENDC
ORG H'00'
GOTO START
ORG 0X04
RETFIE
START
CALL INITIALIZE ; INITIALIZATION OF PORTS & OTHER
REGISERS
INITIALIZE
BCF STATUS,RP1
BSF STATUS,RP0 ;CHANGE TO BANK1
MOVLW B'11000000' ;RC6 & RC7 AS INPUT PORTS
MOVWF TRISC
BCF STATUS,RP0
BSF RCSTA,SPEN ;SERIAL PORT ENABLE
BSF STATUS,RP0
BCF PIE1,TXIE ;DISABLES THE USART TRANSMIT INTRUPT
BCF TXSTA,TX9 ;SELECT 8-BIT TRANSMISSION
RETURN
TRANSMIT
BSF STATUS,RP0
BSF TXSTA,TXEN ;TRANSMIT ENABLED
97
98
BTFSS TXSTA,TRMT ;WAIT UNTILL TSR REGISTER IS EMPTY
GOTO $-1
BCF STATUS,RP0
MOVF DATA1,F ;MOVE DATA TO WORKIN REGISTER
MOVWF TXREG ;MOVE DATA TO TRANSMIT REGISTER
BSF STATUS,RP0
BTFSS TXSTA,TRMT ;WAIT UNTILL TSR REGISTER IS EMPTY
GOTO $-1
RETURN
USART_RECEIVE
BCF STATUS,RP0
BSF RCSTA,CREN
BTFSS PIR1,RCIF
GOTO $-1
MOVF RCREG,W
MOVWF DATA1
CALL TRANSMIT
NOP
GOTO LOOP
END
RESULT:
Thus the assembly program for USART Communication in asynchronous mode was
written and executed. The output was verified in the PIC16F877 kit.
99