SlideShare a Scribd company logo
M.SARASWATHI
Associate Professor
Department of ECE
Panimalar Engineering College
MICROCONTROLLER PROGRAMMING - AN OVERVIEW
A Webinar on
Contents
1. Why programming is important?
2. Input and Output devices for
microcontroller
3. Application of Microcontroller
4. Interfacing Keypad with
microcontroller
5. Keypad Matrix Scanning concept.
6. ALP for interfacing keypad with
LCD.
2
Why Programming is important?
There are three types or levels of
Programming Languages for
8051 Microcontroller.
1. Machine Language
2. Assembly Language
3. High-level Language
Programming in the sense of Microcontrollers means writing
a sequence of instructions to perform a predefined task.
3
 Toys movement of Left,
Right – both legs and
hands is Predefined Task
JOB OPPORTUNITY
Microcontroller Programming
4
More than 650 jobs daily
1. Senior Application & Design Support Engineer (Peenya Loc)
600000 - 900000 INR P.A.
2. Hardware Design Engineer
160000 - 420000 INR P.A.
3. Embedded Software Design Engineer
₹ 3,00,000 - 8,00,000 P.A.
4. Senior Engineer - Embedded Development –
Microcontroller/qt/c++ - Contactx
300000 - 600000 INR P.A.
5. Embedded Software Engineer
Zettaone Technologies India Pvt. Ltd
300000 - 600000 INR P.A.
JOB OPPORTUNITY
Microcontroller Programming- Fresher
Samples of South Indian companies
5
 Assembly Language is a pseudo-English representation
of the Machine Language.
 The 8051 Microcontroller Assembly Language is a
combination of English like words called Mnemonics
and Hexadecimal codes.
 It is also a low level language and requires extensive
understanding of the architecture of the Microcontroller.
Why Assembly Language?
6
 The Programs written in Assembly gets executed faster and
they occupy less memory.
 With the help of Assembly Language, you can directly
exploit all the features of a Microcontroller.
 Using Assembly Language, you can have direct and
accurate control of all the Microcontroller’s resources like
I/O Ports, RAM, SFRs, etc.
 Compared to High-level Languages, Assembly Language
has less rules and restrictions.
Advantage of Assembly Language Programming
7
Input and Output devices for microcontroller
8
APPLICATION OF MICROCONTROLLER
9
 Hex key pad is essentially a collection of 16 keys
arranged in the form of a 4×4 matrix.
 Hex key pad usually
have keys representing
numeric 0 to 9 and
characters A to F.
HEX KEYPAD (or) 4x4 MATRIX
10
 The hex keypad has 8 communication lines namely R1,
R2, R3, R4, C1, C2, C3 and C4.
 R1 to R4 represents the four rows.
 C1 to C4 represents the four columns.
 When a particular key is pressed the corresponding row
and column to which the terminals of the key are
connected gets shorted.
11
 The program identifies which key is pressed by a
method known as column scanning.
 In this method a particular row is kept low (other rows
are kept high) and the columns are checked for low.
 If a particular column is found low then that means that
the key connected between that column and the
corresponding row (the row that is kept low) is been
pressed.
For example :
If row R1 is initially kept low and column C1 is found
low during scanning, that means key ‘1’ is pressed.
12
Input
O
U
T
P
U
T
Case 1:
Case 2:
 5v is individually connected to all keys
13
 Initially keep all values as 1.
Input
O
U
T
P
U
T
14
Input
O
U
T
P
U
T
 ROW1 And COLUMN1 IS PRESSED THE KEY IS ‘1’
(R1,C1)
15
Interfacing Keypad with 8051
16
Key Identification
17
COLUMN SCANNING
INPUT ROW - PORT 1.3 to 1.0
R4 to R1
8051
R1=0
INPUT =1110= EH
C1=0: 1110=EH; Display = ‘1’
C2=0: 1101=DH; Display = ‘2’
C3=0: 1011=BH ;Display = ‘3’
C4=0: 0111=7H ;Display = ‘A’
COLUMN OUTPUT
PORT 1.7 to 1.4
C4 to C1
18
COLUMN SCANNING
INPUT ROW - PORT 1.3 to 1.0
R4 to R1
8051
R2=0
INPUT =1101= DH
C1=0: 1110=EH ;Display = ‘4’
C2=0: 1101=DH ;Display = ‘5’
C3=0: 1011=BH ;Display = ‘6’
C4=0: 0111=7H ;Display = ‘B’
COLUMN OUTPUT
PORT 1.7 to 1.4
C4 to C1
19
COLUMN SCANNING
INPUT ROW - PORT 1.3 to 1.0
R4 to R1
8051
R3=0
INPUT =1011= BH
COLUMN OUTPUT
PORT 1.7 to 1.4
C4 to C1
C1=0: 1110=EH;Display= ‘7’
C2=0: 1101=DH;Display= ‘8’
C3=0: 1011=BH;Display= ‘9’
C4=0: 0111=7H;Display= ‘C’
20
COLUMN SCANNING
INPUT ROW - PORT 1.3 to 1.0
R4 to R1
8051
R4=0
INPUT =0111= 7H
COLUMN OUTPUT
PORT 1.7 to 1.4
C4 to C1
C1=0: 1110=EH;Display= ‘E’
C2=0: 1101=DH;Display= ‘0’
C3=0: 1011=BH;Display= ‘F’
C4=0: 0111=7H;Display= ‘D’
21
ASCII LOOK UP TABLE FOR ROW( COLUMN SCANNING)
ORG 300H
Code1: DB ‘0’, ‘1’, ‘2’, ‘A’ ; Row1
Code2: DB ‘4’, ‘5’, ‘6’, ‘B’ ; Row2
Code3: DB ‘7’, ‘8’, ‘9’, ‘C’ ; Row3
Code4: DB ‘E’, ‘0’, ‘E’,‘D’ ; Row4
(OR)
22
Digit A B C D E F G DP
0 1 1 1 1 1 1 0 0
1 0 1 1 0 0 0 0 0
2 1 1 0 1 1 0 1 0
3 1 1 1 1 0 0 1 0
4 0 1 1 0 0 1 1 0
5 1 0 1 1 0 1 1 0
6 1 0 1 1 1 1 1 0
7 1 1 1 0 0 0 0 0
8 1 1 1 1 1 1 1 0
9 1 1 1 1 0 1 1 0
ASCII LOOK UP TABLE FOR ROW( COLUMN SCANNING)
23
Digit A B C D E F G DP
A 1 1 1 0 1 1 1 0
B 0 0 1 1 1 1 1 0
C 1 0 0 1 1 1 0 0
D 0 1 1 1 1 0 1 0
E 1 0 0 1 1 1 1 0
F 1 0 0 0 1 1 1 0
24
LUT:
DB 0 1 1 0 0 0 0 0
DB 1 1 0 1 1 0 1 0
DB 1 1 1 1 0 0 1 0
DB 1 1 1 0 1 1 1 0
DB 0 1 1 0 0 1 1 0
DB 1 0 1 1 0 1 1 0
DB 1 0 1 1 1 1 1 0
DB 0 0 1 1 1 1 1 0
DISPLAY OF LCD DEVICE
 Label DB can be called as a Look Up Table (LUT).
 Label DB is known as Define Byte – which defines 8 Bit.
25
DB 1 1 1 0 0 0 0 0
DB 1 1 1 1 1 1 1 0
DB 1 1 1 1 0 1 1 0
DB 1 0 0 1 1 1 0 0
DB 1 0 0 1 1 1 1 0
DB 1 1 1 1 1 1 0 0
DB 1 0 0 0 1 1 1 0
DB 0 1 1 1 1 0 1 0
26
1. Initializes PORT 0 as an output port by writing all 0’s to
it
2. PORT 1 as an input port by writing all 1’s to it.
3. Then make Row 1 ‘Low’ by clearing P1.0 and scan the
columns one by one for low using JB instruction.
4. If column C1 is found ‘Low’, that means KEY ‘1’ is
pressed.
5. Accumulator is loaded by zero (A=0) and DISPLAY
subroutine is called.
ABOUT THE PROGRAM
27
6. The display subroutine adds the content in A with the
starting address of LUT stored in DPTR (A+DPTR).
7. Load A with the data to which the resultant address
points (using instruction MOVC A,@A+DPTR).
8. The present data in A will be the digit drive pattern for
the current key press.
9. This pattern is put to Port 0 for display.
10. This way the program scans for each key one by one
and puts it on the display if it is found to be pressed.
28
PROGRAM:
ORG 00H
MOV DPTR,#LUT ; moves starting address of LUT to DPTR
MOV A,#11111111B ; loads A with all 1's
MOV P0,#00000000B ; initializes P0 as output port
BACK: MOV P1,#11111111B ;loads P1 with all 1's
CLR P1.0 ;makes row 1 low
JB P1.4,NEXT1 ;checks whether column 1 is low and
//jumps to NEXT1 if not low
MOV A,#0D ; loads a with 0D if column is low (that
//means key 1 is pressed)
ACALL DISPLAY ;calls DISPLAY subroutine
NEXT1: JB P1.5,NEXT2 ; checks whether column 2 is
// low and so on...
MOV A,#1D
ACALL DISPLAY
29
NEXT2: JB P1.6,NEXT3
MOV A,#2D
ACALL DISPLAY
NEXT3: JB P1.7,NEXT4
MOV A,#3D
ACALL DISPLAY
NEXT4: SETB P1.0
CLR P1.1
JB P1.4,NEXT5
MOV A,#4D
ACALL DISPLAY
NEXT5: JB P1.5,NEXT6
MOV A,#5D
ACALL DISPLAY
30
NEXT6: JB P1.6,NEXT7
MOV A,#6D
ACALL DISPLAY
NEXT7: JB P1.7,NEXT8
MOV A,#7D
ACALL DISPLAY
NEXT8: SETB P1.1
CLR P1.2
JB P1.4,NEXT9
MOV A,#8D
ACALL DISPLAY
NEXT9: JB P1.5,NEXT10
MOV A,#9D
ACALL DISPLAY
31
NEXT10: JB P1.6,NEXT11
MOV A,#10D
ACALL DISPLAY
NEXT11: JB P1.7,NEXT12
MOV A,#11D
ACALL DISPLAY
NEXT12: SETB P1.2
CLR P1.3
JB P1.4,NEXT13
MOV A,#12D
ACALL DISPLAY
NEXT13: JB P1.5,NEXT14
MOV A,#13D
ACALL DISPLAY
32
NEXT14: JB P1.6,NEXT15
MOV A,#14D
ACALL DISPLAY
NEXT15: JB P1.7,BACK
MOV A,#15D
ACALL DISPLAY
LJMP BACK
DISPLAY: MOVC A,@A+DPTR ; gets digit drive pattern for
//the current key from LUT
MOV P0,A ;puts corresponding digit drive
//pattern into P0
RET
33
LUT:
DB 01100000B // Look up table starts here
DB 11011010B
DB 11110010B
DB 11101110B
DB 01100110B
DB 10110110B
DB 10111110B
DB 00111110B
DB 11100000B
DB 11111110B
DB 11110110B
DB 10011100B
DB 10011110B
DB 11111100B
DB 10001110B
DB 01111010B
END
34
35
36

More Related Content

DOCX
Keypad interfacing 8051 -NANOCDAC
PPTX
Key board interfacing with 8051
DOCX
RELIABLE NoC ROUTER ARCHITECTURE DESIGN USING IBM 130NM TECHNOLOGY
PPT
Lcd & keypad
PPTX
Control Word
PPT
Ports 0f 8051
PDF
8051 Microcontroller I/O ports
PPTX
Subroutine in 8051 microcontroller
Keypad interfacing 8051 -NANOCDAC
Key board interfacing with 8051
RELIABLE NoC ROUTER ARCHITECTURE DESIGN USING IBM 130NM TECHNOLOGY
Lcd & keypad
Control Word
Ports 0f 8051
8051 Microcontroller I/O ports
Subroutine in 8051 microcontroller

What's hot (17)

PPTX
8051 i/o port circuit
PPTX
8051 basic programming
PDF
3 jump, loop and call instructions
PPT
8279 d
PPT
I o ports and timers of 8051
PPTX
PPT
8051 ports
PPT
Microcontroller 8051 By Mitesh kumar
PDF
8051 assembly programming
PPT
Interfacing keypad
PDF
6 arithmetic logic inst and prog
PDF
5 addressing modes
PPT
Interfacing LCD with 8051 Microcontroller
PDF
Embedded system (Chapter 3) io_port_programming
PDF
Embedded systems io programming
PDF
Introduction to Embedded C for 8051 and Implementation of Timer and Interrupt...
PPT
int 21,16,09 h
8051 i/o port circuit
8051 basic programming
3 jump, loop and call instructions
8279 d
I o ports and timers of 8051
8051 ports
Microcontroller 8051 By Mitesh kumar
8051 assembly programming
Interfacing keypad
6 arithmetic logic inst and prog
5 addressing modes
Interfacing LCD with 8051 Microcontroller
Embedded system (Chapter 3) io_port_programming
Embedded systems io programming
Introduction to Embedded C for 8051 and Implementation of Timer and Interrupt...
int 21,16,09 h
Ad

Similar to Microcontroller- An overview (20)

PPT
Presentation2 1-150523155048-lva1-app6892
PDF
Combine the keypad and LCD codes in compliance to the following requ.pdf
PDF
Microcontroladores: El microcontrolador 8051 con LCD 16x2
DOCX
Basic standard calculator
PPTX
MPMC Architecture of 8085 Microprocessor and Programming.pptx
PPSX
Hex keypad
PDF
Keypad Interfacing with 8051 Microcontroller
PPTX
keypadinetrface-"Interfacing a Keypad with 8051: A Step-by-Step Approach to E...
PPTX
Embedded system and Internet of things-1.pptx
PDF
Mic practicals
PDF
8051 Architecture, blocks and salient features
PPTX
PPTX
Applications of microcontroller(8051)
PDF
Switch Control and Time Delay - Keypad
PPTX
Introduction to Computer System. 8085/8086 architecture
PDF
microprocessor MICROPROCESSOR 8085 MICROPROCESSOR 8085
PPT
Interfacing ics for microprocessor
PPTX
Basic of Firmware & Embedded Software Programming in C
PPTX
Micro c lab3(ssd)
PDF
Lecture mp 7(interface)
Presentation2 1-150523155048-lva1-app6892
Combine the keypad and LCD codes in compliance to the following requ.pdf
Microcontroladores: El microcontrolador 8051 con LCD 16x2
Basic standard calculator
MPMC Architecture of 8085 Microprocessor and Programming.pptx
Hex keypad
Keypad Interfacing with 8051 Microcontroller
keypadinetrface-"Interfacing a Keypad with 8051: A Step-by-Step Approach to E...
Embedded system and Internet of things-1.pptx
Mic practicals
8051 Architecture, blocks and salient features
Applications of microcontroller(8051)
Switch Control and Time Delay - Keypad
Introduction to Computer System. 8085/8086 architecture
microprocessor MICROPROCESSOR 8085 MICROPROCESSOR 8085
Interfacing ics for microprocessor
Basic of Firmware & Embedded Software Programming in C
Micro c lab3(ssd)
Lecture mp 7(interface)
Ad

Recently uploaded (20)

PDF
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PPT
Total quality management ppt for engineering students
PPTX
Current and future trends in Computer Vision.pptx
PPTX
communication and presentation skills 01
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
Soil Improvement Techniques Note - Rabbi
PPT
introduction to datamining and warehousing
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PPT
A5_DistSysCh1.ppt_INTRODUCTION TO DISTRIBUTED SYSTEMS
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
UNIT 4 Total Quality Management .pptx
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PDF
Abrasive, erosive and cavitation wear.pdf
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
UNIT - 3 Total quality Management .pptx
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
Total quality management ppt for engineering students
Current and future trends in Computer Vision.pptx
communication and presentation skills 01
Safety Seminar civil to be ensured for safe working.
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Soil Improvement Techniques Note - Rabbi
introduction to datamining and warehousing
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
A5_DistSysCh1.ppt_INTRODUCTION TO DISTRIBUTED SYSTEMS
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
UNIT 4 Total Quality Management .pptx
Categorization of Factors Affecting Classification Algorithms Selection
Abrasive, erosive and cavitation wear.pdf
Automation-in-Manufacturing-Chapter-Introduction.pdf
UNIT - 3 Total quality Management .pptx
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf

Microcontroller- An overview

  • 1. M.SARASWATHI Associate Professor Department of ECE Panimalar Engineering College MICROCONTROLLER PROGRAMMING - AN OVERVIEW A Webinar on
  • 2. Contents 1. Why programming is important? 2. Input and Output devices for microcontroller 3. Application of Microcontroller 4. Interfacing Keypad with microcontroller 5. Keypad Matrix Scanning concept. 6. ALP for interfacing keypad with LCD. 2
  • 3. Why Programming is important? There are three types or levels of Programming Languages for 8051 Microcontroller. 1. Machine Language 2. Assembly Language 3. High-level Language Programming in the sense of Microcontrollers means writing a sequence of instructions to perform a predefined task. 3  Toys movement of Left, Right – both legs and hands is Predefined Task
  • 5. 1. Senior Application & Design Support Engineer (Peenya Loc) 600000 - 900000 INR P.A. 2. Hardware Design Engineer 160000 - 420000 INR P.A. 3. Embedded Software Design Engineer ₹ 3,00,000 - 8,00,000 P.A. 4. Senior Engineer - Embedded Development – Microcontroller/qt/c++ - Contactx 300000 - 600000 INR P.A. 5. Embedded Software Engineer Zettaone Technologies India Pvt. Ltd 300000 - 600000 INR P.A. JOB OPPORTUNITY Microcontroller Programming- Fresher Samples of South Indian companies 5
  • 6.  Assembly Language is a pseudo-English representation of the Machine Language.  The 8051 Microcontroller Assembly Language is a combination of English like words called Mnemonics and Hexadecimal codes.  It is also a low level language and requires extensive understanding of the architecture of the Microcontroller. Why Assembly Language? 6
  • 7.  The Programs written in Assembly gets executed faster and they occupy less memory.  With the help of Assembly Language, you can directly exploit all the features of a Microcontroller.  Using Assembly Language, you can have direct and accurate control of all the Microcontroller’s resources like I/O Ports, RAM, SFRs, etc.  Compared to High-level Languages, Assembly Language has less rules and restrictions. Advantage of Assembly Language Programming 7
  • 8. Input and Output devices for microcontroller 8
  • 10.  Hex key pad is essentially a collection of 16 keys arranged in the form of a 4×4 matrix.  Hex key pad usually have keys representing numeric 0 to 9 and characters A to F. HEX KEYPAD (or) 4x4 MATRIX 10
  • 11.  The hex keypad has 8 communication lines namely R1, R2, R3, R4, C1, C2, C3 and C4.  R1 to R4 represents the four rows.  C1 to C4 represents the four columns.  When a particular key is pressed the corresponding row and column to which the terminals of the key are connected gets shorted. 11
  • 12.  The program identifies which key is pressed by a method known as column scanning.  In this method a particular row is kept low (other rows are kept high) and the columns are checked for low.  If a particular column is found low then that means that the key connected between that column and the corresponding row (the row that is kept low) is been pressed. For example : If row R1 is initially kept low and column C1 is found low during scanning, that means key ‘1’ is pressed. 12
  • 13. Input O U T P U T Case 1: Case 2:  5v is individually connected to all keys 13
  • 14.  Initially keep all values as 1. Input O U T P U T 14
  • 15. Input O U T P U T  ROW1 And COLUMN1 IS PRESSED THE KEY IS ‘1’ (R1,C1) 15
  • 18. COLUMN SCANNING INPUT ROW - PORT 1.3 to 1.0 R4 to R1 8051 R1=0 INPUT =1110= EH C1=0: 1110=EH; Display = ‘1’ C2=0: 1101=DH; Display = ‘2’ C3=0: 1011=BH ;Display = ‘3’ C4=0: 0111=7H ;Display = ‘A’ COLUMN OUTPUT PORT 1.7 to 1.4 C4 to C1 18
  • 19. COLUMN SCANNING INPUT ROW - PORT 1.3 to 1.0 R4 to R1 8051 R2=0 INPUT =1101= DH C1=0: 1110=EH ;Display = ‘4’ C2=0: 1101=DH ;Display = ‘5’ C3=0: 1011=BH ;Display = ‘6’ C4=0: 0111=7H ;Display = ‘B’ COLUMN OUTPUT PORT 1.7 to 1.4 C4 to C1 19
  • 20. COLUMN SCANNING INPUT ROW - PORT 1.3 to 1.0 R4 to R1 8051 R3=0 INPUT =1011= BH COLUMN OUTPUT PORT 1.7 to 1.4 C4 to C1 C1=0: 1110=EH;Display= ‘7’ C2=0: 1101=DH;Display= ‘8’ C3=0: 1011=BH;Display= ‘9’ C4=0: 0111=7H;Display= ‘C’ 20
  • 21. COLUMN SCANNING INPUT ROW - PORT 1.3 to 1.0 R4 to R1 8051 R4=0 INPUT =0111= 7H COLUMN OUTPUT PORT 1.7 to 1.4 C4 to C1 C1=0: 1110=EH;Display= ‘E’ C2=0: 1101=DH;Display= ‘0’ C3=0: 1011=BH;Display= ‘F’ C4=0: 0111=7H;Display= ‘D’ 21
  • 22. ASCII LOOK UP TABLE FOR ROW( COLUMN SCANNING) ORG 300H Code1: DB ‘0’, ‘1’, ‘2’, ‘A’ ; Row1 Code2: DB ‘4’, ‘5’, ‘6’, ‘B’ ; Row2 Code3: DB ‘7’, ‘8’, ‘9’, ‘C’ ; Row3 Code4: DB ‘E’, ‘0’, ‘E’,‘D’ ; Row4 (OR) 22
  • 23. Digit A B C D E F G DP 0 1 1 1 1 1 1 0 0 1 0 1 1 0 0 0 0 0 2 1 1 0 1 1 0 1 0 3 1 1 1 1 0 0 1 0 4 0 1 1 0 0 1 1 0 5 1 0 1 1 0 1 1 0 6 1 0 1 1 1 1 1 0 7 1 1 1 0 0 0 0 0 8 1 1 1 1 1 1 1 0 9 1 1 1 1 0 1 1 0 ASCII LOOK UP TABLE FOR ROW( COLUMN SCANNING) 23
  • 24. Digit A B C D E F G DP A 1 1 1 0 1 1 1 0 B 0 0 1 1 1 1 1 0 C 1 0 0 1 1 1 0 0 D 0 1 1 1 1 0 1 0 E 1 0 0 1 1 1 1 0 F 1 0 0 0 1 1 1 0 24
  • 25. LUT: DB 0 1 1 0 0 0 0 0 DB 1 1 0 1 1 0 1 0 DB 1 1 1 1 0 0 1 0 DB 1 1 1 0 1 1 1 0 DB 0 1 1 0 0 1 1 0 DB 1 0 1 1 0 1 1 0 DB 1 0 1 1 1 1 1 0 DB 0 0 1 1 1 1 1 0 DISPLAY OF LCD DEVICE  Label DB can be called as a Look Up Table (LUT).  Label DB is known as Define Byte – which defines 8 Bit. 25
  • 26. DB 1 1 1 0 0 0 0 0 DB 1 1 1 1 1 1 1 0 DB 1 1 1 1 0 1 1 0 DB 1 0 0 1 1 1 0 0 DB 1 0 0 1 1 1 1 0 DB 1 1 1 1 1 1 0 0 DB 1 0 0 0 1 1 1 0 DB 0 1 1 1 1 0 1 0 26
  • 27. 1. Initializes PORT 0 as an output port by writing all 0’s to it 2. PORT 1 as an input port by writing all 1’s to it. 3. Then make Row 1 ‘Low’ by clearing P1.0 and scan the columns one by one for low using JB instruction. 4. If column C1 is found ‘Low’, that means KEY ‘1’ is pressed. 5. Accumulator is loaded by zero (A=0) and DISPLAY subroutine is called. ABOUT THE PROGRAM 27
  • 28. 6. The display subroutine adds the content in A with the starting address of LUT stored in DPTR (A+DPTR). 7. Load A with the data to which the resultant address points (using instruction MOVC A,@A+DPTR). 8. The present data in A will be the digit drive pattern for the current key press. 9. This pattern is put to Port 0 for display. 10. This way the program scans for each key one by one and puts it on the display if it is found to be pressed. 28
  • 29. PROGRAM: ORG 00H MOV DPTR,#LUT ; moves starting address of LUT to DPTR MOV A,#11111111B ; loads A with all 1's MOV P0,#00000000B ; initializes P0 as output port BACK: MOV P1,#11111111B ;loads P1 with all 1's CLR P1.0 ;makes row 1 low JB P1.4,NEXT1 ;checks whether column 1 is low and //jumps to NEXT1 if not low MOV A,#0D ; loads a with 0D if column is low (that //means key 1 is pressed) ACALL DISPLAY ;calls DISPLAY subroutine NEXT1: JB P1.5,NEXT2 ; checks whether column 2 is // low and so on... MOV A,#1D ACALL DISPLAY 29
  • 30. NEXT2: JB P1.6,NEXT3 MOV A,#2D ACALL DISPLAY NEXT3: JB P1.7,NEXT4 MOV A,#3D ACALL DISPLAY NEXT4: SETB P1.0 CLR P1.1 JB P1.4,NEXT5 MOV A,#4D ACALL DISPLAY NEXT5: JB P1.5,NEXT6 MOV A,#5D ACALL DISPLAY 30
  • 31. NEXT6: JB P1.6,NEXT7 MOV A,#6D ACALL DISPLAY NEXT7: JB P1.7,NEXT8 MOV A,#7D ACALL DISPLAY NEXT8: SETB P1.1 CLR P1.2 JB P1.4,NEXT9 MOV A,#8D ACALL DISPLAY NEXT9: JB P1.5,NEXT10 MOV A,#9D ACALL DISPLAY 31
  • 32. NEXT10: JB P1.6,NEXT11 MOV A,#10D ACALL DISPLAY NEXT11: JB P1.7,NEXT12 MOV A,#11D ACALL DISPLAY NEXT12: SETB P1.2 CLR P1.3 JB P1.4,NEXT13 MOV A,#12D ACALL DISPLAY NEXT13: JB P1.5,NEXT14 MOV A,#13D ACALL DISPLAY 32
  • 33. NEXT14: JB P1.6,NEXT15 MOV A,#14D ACALL DISPLAY NEXT15: JB P1.7,BACK MOV A,#15D ACALL DISPLAY LJMP BACK DISPLAY: MOVC A,@A+DPTR ; gets digit drive pattern for //the current key from LUT MOV P0,A ;puts corresponding digit drive //pattern into P0 RET 33
  • 34. LUT: DB 01100000B // Look up table starts here DB 11011010B DB 11110010B DB 11101110B DB 01100110B DB 10110110B DB 10111110B DB 00111110B DB 11100000B DB 11111110B DB 11110110B DB 10011100B DB 10011110B DB 11111100B DB 10001110B DB 01111010B END 34
  • 35. 35
  • 36. 36