Experiment 4 EEE 226 PDF
Experiment 4 EEE 226 PDF
Experiment 4 EEE 226 PDF
Objectives:
Equipment
- LCD
Introduction
A liquid crystal display (LCD) is a thin, flat display device made up of any number color or
monochrome pixels arrayed in front of a light source or reflector. It is often utilized in battery-
powered electronic devices because it uses very small amounts of electric power.
The LCD is finding widespread uses replacing LEDs. This is due to declining prices of LCDs,
the ability to display numbers, characters and graphics (in contrast to LEDs, which are limited
to numbers and a few characters) and ease of programming for characters and graphics.
Below are commands to send data to LCD with a time delay using port 1 and port 2 of 8051
(refer to “The 8051 Microcontroller and Embedded Systems – using assembly and C” Mazidi.
Table 4.1 and Table 4.2 show the function of each pin and command codes for LCD
instruction.
1 Gnd -- Ground
6 E I/O Enable
2 Return home
Please set “The Update Frequency” to 100 before run the program.
; function set
CLR P1.7 ; |
CLR P1.6 ; |
SETB P1.5 ; |
CLR P1.4 ; | high nibble set
SETB P1.2 ; |
CLR P1.2 ; | negative edge on E
SETB P1.2 ; |
CLR P1.2 ; | negative edge on E
; same function set high nibble sent
;a second time
SETB P1.2 ; |
CLR P1.2 ; | negative edge on E
; function set low nibble sent
CALL delay ; wait for BF to clear
SETB P1.6 ; |
SETB P1.5 ; |low nibble set
SETB P1.2 ; |
CLR P1.2 ; | negative edge on E
SETB P1.2 ; |
CLR P1.2 ; | negative edge on E
SETB P1.7 ; |
SETB P1.6 ; |
SETB P1.5 ; |
SETB P1.4 ; | low nibble set
SETB P1.2 ; |
CLR P1.2 ; | negative edge on E
; send data
SETB P1.3 ; clear RS - indicates that data is being
;sent to module
MOV R1, #30H ; data to be sent to LCD is stored in 8051 RAM,
;starting at location 30H
loop:
MOV A, @R1 ; move data pointed to by R1 to A
JZ finish ; if A is 0, then end of data has been
;reached - jump out of loop
CALL sendCharacter ; send data in A to LCD module
INC R1 ; point to next piece of data
JMP loop ; repeat
finish:
JMP $
sendCharacter:
MOV C, ACC.7 ; |
MOV P1.7, C ; |
MOV C, ACC.6 ; |
MOV P1.6, C ; |
MOV C, ACC.5 ; |
SETB P1.2 ; |
CLR P1.2 ; | negative edge on E
MOV C, ACC.3 ; |
MOV P1.7, C ; |
MOV C, ACC.2 ; |
MOV P1.6, C ; |
MOV C, ACC.1 ; |
MOV P1.5, C ; |
MOV C, ACC.0 ; |
MOV P1.4, C ; | low nibble set
SETB P1.2 ; |
CLR P1.2 ; | negative edge on E
delay:
MOV R0, #50
DJNZ R0, $
RET
TASK
Based on the output that you can see, understand each of the instructions, and then report the
observation in terms of why you need those particular instructions in the code. You also need
to report the function each of the subroutines, such as “delay”, “finish” and so on.
Please do the screenshot of the output on LCD and attach it in the lab report.