Book (EN)
Book (EN)
Privacy: This book and its contents should only be used by you.
Do not lend or copy the book to others.
PREFACE
This book has been meticulously prepared for the
Microprocessors and Programming course, one of the 5th-
semester courses offered by the Mechatronics Engineering at
Yıldız Technical University. The book comprises nine
experiments supplemented with essential information required
for their successful execution.
In the experiments, Microchip integrated circuits were utilized
in the RISC structure, which features Harvard architecture
capable of data and commands through separate channels and
executing almost every command in a single cycle.
The book contains experiments written in both assembly and C
programming languages. While becoming proficient in
assembly code may require more time than C, it significantly
contributes to a deeper understanding of basic instruction sets,
processor units, memory addresses, integrated inputs and
outputs, and fundamental computer architecture.
We sincerely hope that this book serves as an invaluable
educational resource, providing practical examples that enhance
the understanding of the theoretical concepts covered in the
course.
i
MKT3811: Microprocessors and Programming
ii
MKT3811: Microprocessors and Programming
TABLE OF CONTENTS
PREFACE .............................................................................................................i
TABLE OF CONTENTS.................................................................................... iii
1. BASIC INFORMATION ................................................................................. 1
1.1. Theoretical Information ........................................................................... 1
1.1.1. Binary, Hexadecimal and Decimal Conversions .............................. 1
1.1.2. Logic Gates and Logic Circuits ....................................................... 6
1.2. Electronic Components ............................................................................ 9
1.2.1. PIC16F887....................................................................................... 9
1.2.2. Fixed Resistors .............................................................................. 19
1.2.3. Variable Resistors .......................................................................... 22
1.2.4. Capacitors ...................................................................................... 22
1.2.5. LED ............................................................................................... 25
1.2.6. Button ............................................................................................ 27
1.2.7. Crystal ........................................................................................... 29
1.2.8. Keypad........................................................................................... 31
1.2.9. LCD Screen ................................................................................... 32
1.2.10. 7 – Segment Display .................................................................... 35
1.3. Basic Circuit Building Information........................................................ 37
1.4. Used Programs ....................................................................................... 42
1.4.1. CCS C ............................................................................................ 42
1.4.2. MPLAB IDE .................................................................................. 44
1.4.3. MPLAB IPE .................................................................................. 50
1.4.4. Proteus ISIS ................................................................................... 58
1.5. Equivalent Microcontrollers .................................................................. 65
1.5.1. Differences Between 16F887 and 16F877A .................................. 65
1.5.2. Differences Between 16F877 and 16F877A .................................. 65
1.5.3. Configuration Settings for Equivalent Microcontrollers ................ 66
1.6. 16F88X Configuration Settings ............................................................. 72
1.6.1. CONFIG1: Configuration Word Register 1 ................................... 72
1.6.2. CONFIG2: Configuration Word Register 2 ................................... 76
2. A LIST OF MATERIALS ............................................................................. 77
3. EXPERIMENTS ............................................................................................ 78
3.1. Experiment 1: Digital I/O ...................................................................... 78
3.1.1. Preliminary Study .......................................................................... 78
3.1.2. A list of materials .......................................................................... 78
3.1.3. Purpose of Experiment .................................................................. 79
3.1.4. Experimental Procedure ................................................................. 79
3.2. Experiment 2: Counter ........................................................................... 86
3.2.1. Preliminary Study .......................................................................... 86
3.2.2. A list of materials .......................................................................... 86
iii
MKT3811: Microprocessors and Programming
iv
MKT3811: Microprocessors and Programming
1. BASIC INFORMATION
1.1. Theoretical Information
1.1.1. Binary, Hexadecimal and Decimal Conversions
Due to the different needs arising over time, various
number systems have been developed. The decimal system,
which consists of the ten digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, is
the number system that is commonly used on a daily basis.
However, the binary system, which consists of only two digits
(0 and 1), is more appropriate for computers, as their circuits
can only represent open or closed states. 0 represents the closed
state in the binary system, while 1 represents the on state.
Hexadecimal numbers, also referred to as hex, have a base of
16. Because the binary representation of large numbers is
cumbersome, hexadecimal numbers are primarily employed to
abbreviate the binary system. In CCS C programming,
hexadecimal numbers must be preceded by 0x to distinguish
them from variable names. For instance, 14 is a decimal number
in C, but 0x14 represents a hexadecimal number (which is
equivalent to 20 in decimal). Understanding the interconversion
of these number systems is critical in avoiding such
complexities.
When converting a decimal number to a binary number,
division should be carried out until the quotient is less than 2.
Then, the remainder should be written from left to right in order,
starting from the last quotient to the first quotient. An example
transformation is given in Figure 1.
1
MKT3811: Microprocessors and Programming
2
MKT3811: Microprocessors and Programming
3
MKT3811: Microprocessors and Programming
4
MKT3811: Microprocessors and Programming
5
MKT3811: Microprocessors and Programming
6
MKT3811: Microprocessors and Programming
7
MKT3811: Microprocessors and Programming
8
MKT3811: Microprocessors and Programming
Figure 8: Creating the NOT function with CMOS (left) and TTL (right)
structures
9
MKT3811: Microprocessors and Programming
10
MKT3811: Microprocessors and Programming
Features
Program Memory Type Flash
Program Memory Size (KB) 14
CPU Speed (MIPS/DMIPS) 5
Data EEPROM (bytes) 256
Capture/Comparison/PWM (CCP) 1
Maximum 8 Bit Digital Timers 2
Number of ADCs 1
ADC Channels 14
Maximum ADC Resolution (bits) 10
Number of Comparators 2
Temperature Range Minimum -40
Temperature Range Maximum 125
Operating Voltage Maximum (V) 5.5
Operating Voltage Minimum (V) 2
Number of Pins 40
Low Power None
11
MKT3811: Microprocessors and Programming
12
MKT3811: Microprocessors and Programming
Input Output
Name Function Description
Type Type
RA0/ RA0 TTL CMOS General purpose I/O.
AN0/ AN0 AN — A/D Channel 0 input.
ULP ULPW
WU/C AN — Ultra Low-Power Wake-up input.
U
12IN0
C12IN0
- AN — Comparator C1 or C2 negative input.
-
RA1/ RA1 TTL CMOS General purpose I/O.
AN1/ AN1 AN — A/D Channel 1 input.
C12I C12IN1
N1- AN — Comparator C1 or C2 negative input.
-
RA2/ RA2 TTL CMOS General purpose I/O.
AN2/ AN2 AN — A/D Channel 2.
VREF-
VREF- AN — A/D Negative Voltage Reference input.
/CVRE
F/C2I CVREF — AN Comparator Voltage Reference output.
N+ C2IN+ AN — Comparator C2 positive input.
RA3/ RA3 TTL CMOS General purpose I/O.
AN3/ AN3 AN — A/D Channel 3.
VREF+
/C1IN VREF+ AN — A/D Positive Voltage Reference input.
+ C1IN+ AN — Comparator C1 positive input.
RA4/ RA4 TTL CMOS General purpose I/O.
T0CK
T0CKI ST — Timer0 clock input.
I/C1O
UT C1OUT — CMOS Comparator C1 output.
RA5/ RA5 TTL CMOS General purpose I/O.
AN4/ AN4 AN — A/D Channel 4.
SS/C2 SS ST — Slave Select input.
OUT C2OUT — CMOS Comparator C2 output.
RA6/ RA6 TTL CMOS General purpose I/O.
OSC2 OSC2 — XTAL Crystal/Resonator.
/CLK CLKO
OUT — CMOS FOSC/4 output.
UT
RA7/ RA7 TTL CMOS General purpose I/O.
OSC1 OSC1 XTAL — Crystal/Resonator.
/CLKI External clock input/RC oscillator
N CLKIN ST —
connection.
13
MKT3811: Microprocessors and Programming
14
MKT3811: Microprocessors and Programming
ICSPD
ST TTL ICSP™ Data I/O.
AT
RC0/ RC0 ST CMOS General purpose I/O.
T1OS
T1OSO — XTAL Timer1 oscillator output.
O/T1
CKI T1CKI ST — Timer1 clock input.
RC1/ RC1 ST CMOS General purpose I/O.
T1OS
T1OSI XTAL — Timer1 oscillator input.
I/CCP
2 CCP2 ST CMOS Capture/Compare/PWM2.
15
MKT3811: Microprocessors and Programming
Legend:
TTL = TTL compatible input ST = Schmitt trigger input with CMOS levels
OD = Open drain
16
MKT3811: Microprocessors and Programming
The oscillator pins for the PIC16F887 are pins 13 (OSC1) and
14 (OSC2). In order to obtain the appropriate oscillator
frequency, 22 pF capacitors can be connected to pins 13 and 14.
The reset connection is used to prevent the microcontroller from
resetting itself. Pin 1 of PIC16F887 is active in logic 0 state.
Therefore, as long as this pin is logic – 0, the microcontroller
will reset itself. Connecting this pin to 5 V with a 1 kΩ resistor
will bring the pin to the logic - 1 level, that is, it will prevent the
microcontroller from resetting itself. The three basic
connections mentioned are shown in Figure 10.
17
MKT3811: Microprocessors and Programming
18
MKT3811: Microprocessors and Programming
19
MKT3811: Microprocessors and Programming
Silver - 10−2 % 10
20
MKT3811: Microprocessors and Programming
R2
−1
1 1
𝑅𝑒𝑞 = 𝑅1 + 𝑅2 + ⋯ 𝑅𝑒𝑞 = ( + + ⋯)
𝑅1 𝑅2
21
MKT3811: Microprocessors and Programming
1.2.4. Capacitors
Capacitors are passive electronic components
consisting of two or more conductive materials separated by an
insulating material. A capacitor, like a small rechargeable
battery, is an element that creates a potential difference between
its plates and has the capacity to store energy in the form of an
electric charge. There are many different types of capacitors,
from very small capacitor beads used in resonant circuits to
large power factor correction capacitors. However, they are
22
MKT3811: Microprocessors and Programming
23
MKT3811: Microprocessors and Programming
24
MKT3811: Microprocessors and Programming
1.2.5. LED
A light-emitting diode (LED) is a semiconductor device
that emits light when an electric current is passed through it.
Depending on the semiconductor material used and the amount
of doping, an LED will emit a colored light of a specific spectral
wavelength. In addition, LEDs allow current to flow in the
forward direction and block the current in the reverse direction.
The LED symbol is given in Figure 17.
25
MKT3811: Microprocessors and Programming
26
MKT3811: Microprocessors and Programming
1.2.6. Button
A button is a mechanical device used to control (close
– open) the electrical circuit. Alternatively, it can provide an
input for the user interface of an equipment or initiate/terminate
a specific function. They can be manufactured in a variety of
shapes, sizes and configurations depending on design
requirements. Some button types that are frequently used in the
market are given in Figure 19.
27
MKT3811: Microprocessors and Programming
28
MKT3811: Microprocessors and Programming
1.2.7. Crystal
Crystal oscillators work on the principle of the inverse
piezoelectric effect. Although other substances such as
Rochelle salt and tourmaline exhibit a piezoelectric effect, these
oscillators are usually made of quartz crystal because quartz is
inexpensive, naturally occurring, and mechanically strong
compared to others. The crystal in crystal oscillators is precisely
cut and positioned between two metallic plates, as illustrated in
Figure 21a. In reality, the crystal behaves like a series RLC
circuit (Figure 21b) formed by the resistor, capacitor, and coil
components.
29
MKT3811: Microprocessors and Programming
Figure 22: The crystal circuit used to generate the clock signal
30
MKT3811: Microprocessors and Programming
1.2.8. Keypad
The keypad serves as an input device to read and
interpret the user's keystrokes. The 4x4 keypad consists of 4
rows and 4 columns. Keys are placed between rows and
columns. When a key is pressed, a connection is established
between the corresponding row and column. To read the value
of the key, the columns are pulled to the logic -1 level. Once the
corresponding column is powered, the rows are read similar to
a button. This allows for the determination of which row was
pressed in the given column. A diagram illustrating the
connection for the 4x4 keypad is provided in Figure 23.
31
MKT3811: Microprocessors and Programming
32
MKT3811: Microprocessors and Programming
7 D0 Bus line 0
8 D1 Bus line 1
9 D2 Bus line 2
10 D3 Bus line 3
11 D4 Bus line 4
12 D5 Bus line 5
13 D6 Bus line 6
14 D7 Bus line 7
33
MKT3811: Microprocessors and Programming
34
MKT3811: Microprocessors and Programming
Figure 26: Common cathode (left) and common anode (right) 7 – segment
35
MKT3811: Microprocessors and Programming
36
MKT3811: Microprocessors and Programming
Figure 28: Real life structure (left) of common cathode 7 - segment found in
the Proteus library (right)
37
MKT3811: Microprocessors and Programming
38
MKT3811: Microprocessors and Programming
39
MKT3811: Microprocessors and Programming
Figure 32: Male to male jumper cable (top) and USB crocodile cable
(bottom)
40
MKT3811: Microprocessors and Programming
Figure 33: Not pressed (top) and pressed (bottom) conditions for LED on-off
circuit
41
MKT3811: Microprocessors and Programming
42
MKT3811: Microprocessors and Programming
Once the writing the code on the active page have been
finalized, it can be can be compiled using the Compile option,
as shown in Figure 36.
43
MKT3811: Microprocessors and Programming
44
MKT3811: Microprocessors and Programming
45
MKT3811: Microprocessors and Programming
46
MKT3811: Microprocessors and Programming
47
MKT3811: Microprocessors and Programming
48
MKT3811: Microprocessors and Programming
49
MKT3811: Microprocessors and Programming
50
MKT3811: Microprocessors and Programming
51
MKT3811: Microprocessors and Programming
52
MKT3811: Microprocessors and Programming
53
MKT3811: Microprocessors and Programming
54
MKT3811: Microprocessors and Programming
55
MKT3811: Microprocessors and Programming
Figure 58: Error occurred while sending the .hex file to the microcontroller
56
MKT3811: Microprocessors and Programming
57
MKT3811: Microprocessors and Programming
58
MKT3811: Microprocessors and Programming
59
MKT3811: Microprocessors and Programming
60
MKT3811: Microprocessors and Programming
61
MKT3811: Microprocessors and Programming
62
MKT3811: Microprocessors and Programming
63
MKT3811: Microprocessors and Programming
64
MKT3811: Microprocessors and Programming
65
MKT3811: Microprocessors and Programming
66
MKT3811: Microprocessors and Programming
Figure 74: Setting up the LED on – off circuit with PIC16F887 (top) and
PIC16F877A (bottom)
67
MKT3811: Microprocessors and Programming
68
MKT3811: Microprocessors and Programming
Figure 75: Writing the LED on – off code for PIC16F887 (top) and
PIC16F877A (bottom)
69
MKT3811: Microprocessors and Programming
70
MKT3811: Microprocessors and Programming
71
MKT3811: Microprocessors and Programming
bit 13 ̅̅̅̅̅̅̅̅̅̅
𝐃𝐄𝐁𝐔𝐆: In-Circuit Debugger Mode bit
1 = In-Circuit Debugger disabled,
RB6/ICSPCLK and RB7/ICSPDAT are
general purpose I/O pins
0 = In-Circuit Debugger enabled,
RB6/ICSPCLK and RB7/ICSPDAT are
dedicated to the debugger
bit 12 LVP: Low Voltage Programming Enable bit
1 = RB3/PGM pin has PGM function, low
voltage programming enabled
0 = RB3 pin is digital I/O, HV on ̅̅̅̅̅̅̅̅
MCLR must
be used for programming
72
MKT3811: Microprocessors and Programming
73
MKT3811: Microprocessors and Programming
74
MKT3811: Microprocessors and Programming
75
MKT3811: Microprocessors and Programming
76
MKT3811: Microprocessors and Programming
2. A LIST OF MATERIALS
The book features nine assembly and C code
applications that can be implemented using the materials listed
in Table 9.
Table 9: A list of materials
77
MKT3811: Microprocessors and Programming
3. EXPERIMENTS
3.1. Experiment 1: Digital I/O
3.1.1. Preliminary Study
For the preliminary preparation of the experiment, it is
recommended to review the basic circuit building information
provided in Section 1.3, the microcontroller pin configuration
described in Section 1.2.1, and the necessary connections for
the microcontroller, including the crystal connections outlined
in Section 1.2.7, LED connections and limiting resistor
calculations discussed in Section 1.2.5 as well as the pull-up and
pull-down resistor connections for buttons in section 1.2.6.
Also, please refer the last part of Section 1.2.1 to determine the
amount of the maximum current can be sourced from and sinked
in the PIC18F887.
78
MKT3811: Microprocessors and Programming
79
MKT3811: Microprocessors and Programming
LIST p = 16F887
; Controller model introduced
#INCLUDE <p16F887.inc>
; Introduction of MCU library
__config _CONFIG1,b'1110000011100100'
__config _CONFIG2,b'1111100011111111'
; MCU configuration setting
ORG 0x00 ;
Reset vector
BSF STATUS,5
; BANK1 selected
MOVLW B'00000001'
; Binary value assigned to W register
MOVWF TRISD
; Value in W assigned to TRISD register
BCF STATUS,5
; BANK0 selected
MAIN
BTFSC PORTD,0
; Process subcommand if D0=1
; If D0=0 skip subcommand continue from next command
GOTO LEDON
GOTO LEDOFF
LEDON
BSF PORTD,1
; D1 -> Led high
GOTO MAIN
; Endless loop
LEDOFF
BCF PORTD,1
; D1 -> Led low
GOTO MAIN
; Endless loop
END
80
MKT3811: Microprocessors and Programming
81
MKT3811: Microprocessors and Programming
LIST p = 16F887
; Controller model introduced
#INCLUDE <p16F887.inc>
; Introduction of MCU library
__config _CONFIG1,b'1110000011100001'
__config _CONFIG2,b'1111100011111111'
; MCU configuration setting
ORG 0x00
; Reset vector
BSF STATUS,5
; BANK1 selected
MOVLW B'00000001'
; W = 00000001
MOVWF TRISD
; PortD = 00000001
BCF STATUS,5
; BANK0 selected
MAIN
BTFSC PORTD,0
; Process subcommand if D0=1
; Skip subcommand if D0=0
GOTO LEDON
GOTO LEDOFF
LEDON
BSF PORTD,1
; D1 -> Led high
GOTO MAIN
; Endless loop
LEDOFF
BCF PORTD,1
; D1 -> Led low
GOTO MAIN
; Endless loop
END
82
MKT3811: Microprocessors and Programming
83
MKT3811: Microprocessors and Programming
84
MKT3811: Microprocessors and Programming
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
85
MKT3811: Microprocessors and Programming
86
MKT3811: Microprocessors and Programming
87
MKT3811: Microprocessors and Programming
LIST P=16F887
INCLUDE "P16F887.INC"
__config _CONFIG1,b'1110000011100001'
__config _CONFIG2,b'1111100011111111'
ORG H'00'
BSF STATUS,5
; Bank1 selected
MOVLW B'00000001'
; W=00000001
MOVWF TRISD
; PortD pin 0 is set as input
BCF STATUS,5
; Bank0 selected
CLRF PORTD
MAIN
BTFSS PORTD,0
GOTO MAIN
GOTO BUZZER
BUZZER
BSF PORTD,1
; Activate pin D1
CALL DELAY_2_SEC
; wait 2 seconds
BCF PORTD,1
; Disable pin D1
CALL DELAY_2_SEC
; wait 2 seconds
BTFSC PORTD,0
GOTO BUZZER
GOTO MAIN
88
MKT3811: Microprocessors and Programming
DELAY_ONE_MS
MOVLW D'250'
; count 250 cycles
MOVWF SAYAC
LOOP_ONE_MS
; ~1 millisecond
NOP
DECFSZ SAYAC,F
GOTO LOOP_ONE_MS
RETURN
DELAY_250_MS
MOVLW D'250'
MOVWF SAYAC1
LOOP_250_MS
; ~250 millisecond
CALL DELAY_ONE_MS
DECFSZ SAYAC1,F
GOTO LOOP_250_MS
RETURN
DELAY_2_SEC
; ~2 second
MOVLW D'8'
MOVWF SAYAC2
LOOP_2_SEC
CALL DELAY_250_MS
DECFSZ SAYAC2,F
GOTO LOOP_2_SEC
RETURN
END
89
MKT3811: Microprocessors and Programming
90
MKT3811: Microprocessors and Programming
91
MKT3811: Microprocessors and Programming
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
92
MKT3811: Microprocessors and Programming
93
MKT3811: Microprocessors and Programming
94
MKT3811: Microprocessors and Programming
LIST P=16F887
INCLUDE "P16F887.INC"
__config _CONFIG1,b'1110000011100001'
__config _CONFIG2,b'1111100011111111'
ORG 0x00
GOTO MAIN
ORG 0x04
GOTO TMR0_INT
MAIN
; All inputs/outputs will be assigned digitally
BANKSEL ANSEL
CLRF ANSEL
CLRF ANSELH
; Selecting Bank1
BCF STATUS,6
BSF STATUS,5
MOVLW B'11010111'
; Timer0 presecaler (1/256)
MOVWF OPTION_REG
MOVLW B'10100000'
; GIE and TMR0IE active
MOVWF INTCON
CLRF TRISB
; PortB pins are assigned as outputs
BCF STATUS,5
; Bank0 selected
CLRF PORTB
; PortB outputs are disabled
LOOP
GOTO LOOP
; Endless loop
95
MKT3811: Microprocessors and Programming
TMR0_INT
BCF INTCON,2
; Clear TMR0 overflow interrupt flag bit
MOVLW H'01'
XORWF PORTB,F
; Toggle LED
CLRF TMR0
; Clear timer0
RETFIE
; Return from interrupt subcode
END
96
MKT3811: Microprocessors and Programming
97
MKT3811: Microprocessors and Programming
98
MKT3811: Microprocessors and Programming
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
99
MKT3811: Microprocessors and Programming
100
MKT3811: Microprocessors and Programming
101
MKT3811: Microprocessors and Programming
void main ()
{
set_tris_b(0b00000000); // Port B is completely set
to output
lcd_init(); // This command should be written before
calling the LCD functions
x = 10; // value assigned to variable x
y = 32.6; // value assigned to variable y
102
MKT3811: Microprocessors and Programming
103
MKT3811: Microprocessors and Programming
104
MKT3811: Microprocessors and Programming
Notes…………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
105
MKT3811: Microprocessors and Programming
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
106
MKT3811: Microprocessors and Programming
107
MKT3811: Microprocessors and Programming
108
MKT3811: Microprocessors and Programming
109
MKT3811: Microprocessors and Programming
110
MKT3811: Microprocessors and Programming
111
MKT3811: Microprocessors and Programming
112
MKT3811: Microprocessors and Programming
113
MKT3811: Microprocessors and Programming
114
MKT3811: Microprocessors and Programming
Figure 87: Keypad to be used in real life and equivalent keypad in Proteus
Notes…………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
115
MKT3811: Microprocessors and Programming
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
116
MKT3811: Microprocessors and Programming
117
MKT3811: Microprocessors and Programming
118
MKT3811: Microprocessors and Programming
119
MKT3811: Microprocessors and Programming
120
MKT3811: Microprocessors and Programming
121
MKT3811: Microprocessors and Programming
122
MKT3811: Microprocessors and Programming
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
123
MKT3811: Microprocessors and Programming
124
MKT3811: Microprocessors and Programming
125
MKT3811: Microprocessors and Programming
126
MKT3811: Microprocessors and Programming
127
MKT3811: Microprocessors and Programming
128
MKT3811: Microprocessors and Programming
129
MKT3811: Microprocessors and Programming
130
MKT3811: Microprocessors and Programming
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
131
MKT3811: Microprocessors and Programming
132
MKT3811: Microprocessors and Programming
133
MKT3811: Microprocessors and Programming
134
MKT3811: Microprocessors and Programming
135
MKT3811: Microprocessors and Programming
136
MKT3811: Microprocessors and Programming
137
MKT3811: Microprocessors and Programming
138
MKT3811: Microprocessors and Programming
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
139
MKT3811: Microprocessors and Programming
140
MKT3811: Microprocessors and Programming
141
MKT3811: Microprocessors and Programming
142
MKT3811: Microprocessors and Programming
143
MKT3811: Microprocessors and Programming
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
…………………………………………………………………
144
MKT3811: Microprocessors and Programming
REFERENCES
Akdogan, Erhan & Demir, Mehmet & Aktan, Mehmet & Koru, Ahmet.
(2016). ELECTRIC - ELECTRONICS LABORATORY EXPERIMENT
BOOK.
https://www.microchip.com/en-us/product/PIC16F887
https://www.mikroe.com/ebooks/pic-microcontrollers-programming-in-
assembly/pic16f887-microcontroller-device-overview
https://eepower.com/resistor-guide/resistor-fundamentals/what-is-a-
resistor/#
https://eepower.com/resistor-guide/resistor-applications/pull-up-resistor-
pull-down-resistor/
https://www.electrical4u.com/potentiometer/
https://www.electrical4u.com/crystal-oscillator/
https://www.electronics-tutorials.ws/capacitor/cap_1.html
https://www.electronics-tutorials.ws/blog/7-segment-display-tutorial.html
https://www.electronicwings.com/sensors-modules/4x4-keypad-module
https://www.techtarget.com/whatis/definition/LCD-liquid-crystal-display
145