Professional Documents
Culture Documents
Ee8551 - Microprocessors and Microcontrollers
Ee8551 - Microprocessors and Microcontrollers
AND MICROCONTROLLERS
23 November 2022 KPR Institute of Engineering and Technology, Coimbatore, Tamil Nadu, India1
UNIT V
MICRO CONTROLLER PROGRAMMING &
APPLICATIONS
23 November 2022 KPR Institute of Engineering and Technology, Coimbatore, Tamil Nadu, India2
Programming of 8051
• Programming in the sense of Microcontrollers means writing a
sequence of instructions that are executed by the processor in a
particular order to perform a predefined task. Programming also
involves debugging and troubleshooting of instructions and
instruction sequence to make sure that the desired task is
performed.
• Like any language, Programming Languages have certain words,
grammar and rules. There are three types or levels of
Programming Languages for 8051 Microcontroller.
Machine Language
Assembly Language
High-level Language
23 November 2022 KPR Institute of Engineering and Technology, Coimbatore, Tamil Nadu, India3
Programming of 8051
23 November 2022 KPR Institute of Engineering and Technology, Coimbatore, Tamil Nadu, India5
Simple Programming Exercises
Example 2
Write a program to add the values of locations 50H and 51H and store
the result in locations in 52h and 53H.
23 November 2022 KPR Institute of Engineering and Technology, Coimbatore, Tamil Nadu, India7
Simple Programming Exercises
Example 5
Divide the content of r0 by r1. Store the result in r2 (Quotient)
and r3 (reminder). Then restore the original content of r0.
Mov a, r0 ; get the content of r0 and r1
Mov b, r1 ; in register A and B
Div ab ; divide A by B
Mov r2, a ; store result in r2
Mov r3, b ; and reminder in r3
Mov b, r1 ; again get content of r1 in B
Mul ab ; multiply it by answer
Add a, r3 ; add reminder in new answer
Mov r0, a ; finally restore the content of r0
23 November 2022 KPR Institute of Engineering and Technology, Coimbatore, Tamil Nadu, India8
Interfacing keyboard with 8051
https://youtu.
be/975CS27w16w
Keyboard Interfacing
23 November 2022 KPR Institute of Engineering and Technology, Coimbatore, Tamil Nadu, India9
Interfacing LCD with 8051
https://youtu.be/THmaKk5nJRc
LCD Interfacing
23 November 2022 KPR Institute of Engineering and Technology, Coimbatore, Tamil Nadu, India
15
1. Vss – Ground
2. Vcc- power supply of +5 v
3. Vee- power supply backlight connected to resistor
4. Rs-Register select
Command or data
5. Read/Write
0- write operation
1- Read operation
6.Enable pin
Low-data available
High-data not available
https://youtu.be/pRII3dBKIc8
Stepper Motor Interfacing
23 November 2022 KPR Institute of Engineering and Technology, Coimbatore, Tamil Nadu, India
20
Interfacing DC Motor with 8051
https://youtu.be/kTtt09uX894
DC Motor Interfacing
23 November 2022 KPR Institute of Engineering and Technology, Coimbatore, Tamil Nadu, India
31
23 November 2022 KPR Institute of Engineering and Technology, Coimbatore, Tamil Nadu, India
42
Interfacing Servo Motor with 8051
https://www.youtube.com/watch?
v=ditS0a28Sko
23 November 2022 KPR Institute of Engineering and Technology, Coimbatore, Tamil Nadu, India
43
Servo Motor
Interfacing Relay with 8051
https://youtu.be/t--71LFuTW4
Relay Interfacing
23 November 2022 KPR Institute of Engineering and Technology, Coimbatore, Tamil Nadu, India
49