You are on page 1of 42

A

PRACTICAL TRAINING REPORT


ON
EMBEDDED SYSTEMS
SUBMITTED IN THE PARTIAL FULFILLMENT
OF
BACHELOR OF TECHNOLOGY
IN
Electronics Instrumentation & Control Engg.

Session 2009-2010

SUBMITTED TO: SUBMITTED BY


Dr. Neelam Sharma AJAY KUMAR YADAV
(Incharge) EI&C Deptt. (EI&C 7thSEM)
I.E.T. Alwar (Raj.)
ACKNOWLEDGEMENT

I proudly express my respectful thanks to my esteemed


educational institution I.E.T which has blessed me to continue
my technical education and has provided me a bright future.
I respectfully express my earnest thanks to my worthy sir
Prof.Ramkesh Meena who provided opportunity and
permitted me for practical summer training.
I also respectfully express my earnest thanks to
Gaurav Kumar & Kapil Jindal traineers of the ADVANCED
TECHNOLOGY, who has taken care of all the students in the
aspects and has guided us professionally and technically
helped in completing my training.

Reported

Department of Electronics Instrumentation & Control Engg.


Certificate
This is certify the seminar report entitled “EMBEDED
SYSTEMS” submitted by AJAY KUMAR YADAV under my
supervision is his own work and has been submitted
elsewhere for the award of any degree to the best of my
knowledge and belief.

Prof(Dr.)NEELAM SHARMA. Signature:

H.O.D. (Ms. JOLLY SINGH).

EI&C DEPTT. Senior Lecturer,EI&C

Depearment of Electronics Instrumentation & Control Engg.


A
Training Report
on LCD Display
Using
8051 MCU
Contents
 Introduction.
 8051 Microcontroller.
 Features of 8051 Architecture.
 Microcontroller for Embedded Systems.
 Microcontroller Vs Microprocessor.
 8051 Microcontroller pin diagram & pin function.
 Port structure & operation.
 SFR’s .
 Stack pointer.
 Serial data buffer.
 Basic register.
 Addressing mode.
 LCD Pin Diagram & Pin Description.
 Interfacing of LCD.
 List of Hardware.
 LCD Command Code.
 Embedded C.
Introduction:-

We are living in the Embedded World. You are surrounded with many
embedded products and your daily life largely depends on the proper
functioning of these gadgets. Television, Radio, CD player of your living
room, Washing Machine or Microwave Oven in your kitchen, Card
readers, Access Controllers, Palm devices of your work space enable
you to do many of your tasks very effectively. Apart from all these,
many controllers embedded in your car take care of car operations
between the bumpers and most of the times you tend to ignore all
these controllers.

Theoretically, an embedded controller is a combination of a piece of


microprocessor based hardware and the suitable software to undertake
a specific task.

These days designers have many choices in microprocessors/


microcontrollers. Especially, in 8 bit and 32 bit, the available variety
really may overwhelm even an experienced designer. Selecting a right
microprocessor may turn out as a most difficult first step and it is
getting complicated as new devices continue to pop-up very often.

In the 8 bit segment, the most popular and used architecture is Intel's
8031. Market acceptance of this particular family has driven many
semiconductor manufacturers to develop something new based on this
particular architecture. Even after 25 years of existence, semiconductor
manufacturers still come out with some kind of device using this 8031 core.
8051 Microcontrollers:-

The AT89C51 is a low-power, high-performance CMOS 8-bit


microcomputer with 4 Kbytes of Flash Programmable and Erasable
Read Only Memory (PEROM). The device is manufactured using Atmel's
high density nonvolatile memory technology and is compatible with the
industry standard MCS-51Ô instruction set and pin out. The on-chip
Flash allows the program memory to be reprogrammed in-system or by
a conventional nonvolatile memory programmer. By combining a
versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51
is a powerful microcomputer which provides a highly flexible and cost
effective solution to many embedded control applications.

The AT89C51 provides the following standard features: 4 Kbytes of


Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters, five
vector two-level interrupt architecture, a full duplex serial port, and on-
chip oscillator and clock circuitry. In addition, the AT89C51 is designed
with static logic for operation down to zero frequency and supports two
software selectable power saving modes. The Idle Mode stops the CPU
while allowing the RAM, timer/counters, serial port and interrupt
system to continue functioning. The Power down Mode saves the RAM
contents but freezes the oscillator.
The following list gives the features of the
8051 architecture:-

 Optimized 8 bit CPU for control applications.

  Extensive Boolean processing capabilities.

 64K Program Memory address space.

 4K byte of ROM.

 128 bytes of on chip Data Memory.

 32 Bi-directional and individually addressable I/O lines.

 Two 16 bit timer/counters.

 Full Duplex UART.

 5-vector interrupts structure with priority levels.

 On chip clock oscillator.


Microcontrollers for Embedded Systems:-

In the Literature discussing microprocessors, we often see the term


Embedded System. Microprocessors and Microcontrollers are widely
used in embedded system products. An embedded system product uses
a microprocessor (or Microcontroller) to do one task only. A printer is
an example of embedded system since the processor inside it performs
one task only; namely getting the data and printing it. Contrast this with
a Pentium based PC. A PC can be used for any number of applications
such as word processor, print-server, bank teller terminal, Video game,
network server, or Internet terminal. Software for a variety of
applications can be loaded and run. of course the reason a pc can
perform myriad tasks is that it has RAM memory and an operating
system that loads the application software into RAM memory and lets
the CPU run it.

In an Embedded system, there is only one application software that is


typically burned into ROM. An x86 PC contains or is connected to
various embedded products such as keyboard, printer, modem, disk
controller, sound card, CD-ROM drives, mouse, and so on. Each one of
these peripherals has a Microcontroller inside it that performs only one
task. For example, inside every mouse there is a Microcontroller to
perform the task of finding the mouse position and sending it to the PC.
Microcontroller versus Microprocessor:-

What is the difference between a Microprocessor and Microcontroller?


By microprocessor is meant the general purpose Microprocessors such
as Intel's X86 family (8086, 80286, 80386, 80486, and the Pentium) or
Motorola's 680X0 family (68000, 68010, 68020, 68030, 68040, etc).
These microprocessors contain no RAM, no ROM, and no I/O ports on
the chip itself. For this reason, they are commonly referred to as
general-purpose Microprocessors.

A system designer using a general-purpose microprocessor such as the


Pentium or the 68040 must add RAM, ROM, I/O ports, and timers
externally to make them functional. Although the addition of external
RAM, ROM, and I/O ports makes these systems bulkier and much more
expensive, they have the advantage of versatility such that the designer
can decide on the amount of RAM, ROM and I/O ports needed to fit the
task at hand. This is not the case with Microcontrollers.

A Microcontroller has a CPU (a microprocessor) in addition to a fixed


amount of RAM, ROM, I/O ports, and a timer all on a single chip. In
other words, the processor, the RAM, ROM, I/O ports and the timer are
all embedded together on one chip; therefore, the designer cannot add
any external memory, I/O ports, or timer to it. The fixed amount of on-
chip ROM, RAM, and number of I/O ports in Microcontrollers makes
them ideal for many applications in which cost and space are critical.
8051 microcontroller Pin Diagram and Pin
Functions:-

ALE/PROG: Address Latch Enable output pulse for latching the low byte
of the address during accesses to external memory. ALE is emitted at a
constant rate of 1/6 of the oscillator frequency, for external timing or
clocking purposes, even when there are no accesses to external
memory. (However, one ALE pulse is skipped during each access to
external Data Memory.) This pin is also the program pulse input (PROG)
during EPROM programming.
PSEN: Program Store Enable is the read strobe to external Program
Memory. When the device is executing out of external Program
Memory, PSEN is activated twice each machine cycle (except that two
PSEN activations are skipped during accesses to external Data
Memory). PSEN is not activated when the device is executing out of
internal Program Memory.

EA/VPP: When EA is held high the CPU executes out of internal


Program Memory (unless the Program Counter exceeds 0FFFH in the
80C51). Holding EA low forces the CPU to execute out of external
memory regardless of the Program Counter value. In the 80C31, EA
must be externally wired low. In the EPROM devices, this pin also
receives the programming supply voltage (VPP) during EPROM
programming.

XTAL1: Input to the inverting oscillator amplifier.


XTAL2: Output from the inverting oscillator amplifier.

Port 0: Port 0 is an 8-bit open drain bidirectional port. As an open drain


output port, it can sink eight LS TTL loads. Port 0 pins that have 1s
written to them float, and in that state will function as high impedance
inputs. Port 0 is also the multiplexed low-order address and data bus
during accesses to external memory. In this application it uses strong
internal pull-ups when emitting 1s. Port 0 emits code bytes during
program verification. In this application, external pull-ups are required.
Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pull-ups.
Port 1 pins that have 1s written to them are pulled high by the internal
pull-ups, and in that state can be used as inputs. As inputs, port 1 pins
that are externally being pulled low will source current because of the
internal pull-ups.
Port 2: Port 2 is an 8-bit bidirectional I/O port with internal pull-ups.
Port 2 emits the high-order address byte during accesses to external
memory that use 16-bit addresses. In this application, it uses the strong
internal pull-ups when emitting 1s.
Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. It
also serves the functions of various special features of the 80C51 Family
as follows:
Port Pin Alternate Function
P3.0 RxD (serial input port)
P3.1 TxD (serial output port)
P3.2 INT0 (external interrupt 0)
P3.3 INT1 (external interrupt 1)
P3.4 T0 (timer 0 external input)
P3.5 T1 (timer 1 external input)
P3.6 WR (external data memory write strobe)
P3.7 RD (external data memory read strobe)

VCC: Supply voltage


VSS: Circuit ground potential
Port Structures and Operation:-

All four ports in the 80C51 are bidirectional. Each consists of a latch
(Special Function Registers P0 through P3), an output driver, and an
input buffer. The output drivers of Ports 0 and 2, and the input buffers
of Port 0, are used in accesses to external memory. In this application,
Port 0 outputs the low byte of the external memory address, time-
multiplexed with the byte being written or read. Port 2 outputs the high
byte of the external memory address when the address is 16 bits wide.
Otherwise, the Port 2 pins continue to emit the P2 SFR content.
All the Port 3 pins are multifunctional. They are not only port pins, but
also serve the functions of various special features as listed below:

Port Pin Alternate Function:-


P3.0 RxD (serial input port)
P3.1 TxD (serial output port)
P3.2 INT0 (external interrupt)
P3.3 INT1 (external interrupt)
P3.4 T0 (Timer/Counter 0 external input)
P3.5 T1 (Timer/Counter 1 external input)
P3.6 WR (external Data Memory write strobe)
P3.7 RD (external Data Memory read strobe)
The alternate functions can only be activated if the corresponding bit
latch in the port SFR contains a 1. Otherwise the port pin remains at 0.
Special Function Registers (SFRs):-

A Map of the on-chip memory area called the Special Function


Register (SFR) space is shown in Figure.
In the SFRs not all of the addresses are occupied. Unoccupied addresses
are not implemented on the chip. Read accesses to these addresses will
in general return random data, and write accesses will have no effect.
User software should not write 1s to these unimplemented locations,
since they may be used in other 80C51 Family derivative products
to invoke new features. The functions of the SFRs are described in the
text that follows.

Accumulator:
ACC is the Accumulator register. The mnemonics for Accumulator-
Specific instructions, however, refer to the Accumulator simply as A.
B Register:
The B register is used during multiply and divide operations. For other
instructions it can be treated as another scratch pad register.
Program Status Word:
The PSW register contains program status information as detailed in
Figure.
BIT SYMBOL FUNCTION:-

PSW.7 CY Carry flag.


PSW.6 AC Auxiliary Carry flag. (For BCD operations.)
PSW.5 F0 Flag 0. (Available to the user for general purposes.)
PSW.4 RS1 Register bank select control bit 1.
Set/cleared by software to determine working register bank.
PSW.3 RS0 Register bank select control bit 0.
Set/cleared by software to determine working register bank.
PSW.2 OV Overflow flag.
PSW.1 — User-definable flag.
PSW.0 P Parity flag.
Set/cleared by hardware each instruction cycle to indicate an odd/even
Number of “one” bits in the Accumulator, i.e., even parity.

NOTE: The contents of (RS1, RS0) enable the working register banks as
follows:
(0, 0)— Bank 0 (00H–07H)
(0, 1)— Bank 1 (08H–0fH)
(1, 0)— Bank 2 (10H–17H)
(1, 1)— Bank 3 (18H–17H)
Stack Pointer:-
The Stack Pointer register is 8 bits wide. It is incremented before data is
stored during PUSH and CALL executions. While the stack may reside
anywhere in on-chip RAM, the Stack Pointer is initialized to 07H after a
reset. This causes the stack to begin at locations 08H.
Data Pointer:-
The Data Pointer (DPTR) consists of a high byte (DPH) and a low byte
(DPL). Its intended function is to hold a 16-bit address. It may be
manipulated as a 16-bit register or as two independent 8-bit registers.
Serial Data Buffer:-
The Serial Buffer is actually two separate registers, a transmit buffer
and a receive buffer. When data is moved to SBUF, it goes to the
transmit buffer and is held for serial transmission. (Moving a byte to
SBUF is what initiates the transmission.) When data is moved from
SBUF, it comes from the receive buffer.
Timer Registers Basic to 80C51:-
Register pairs (TH0, TL0), and (TH1, TL1) are the 16-bit Counting
registers for Timer/Counters 0 and 1, respectively.
Control Register for the 80C51:-
Special Function Registers IP, IE, TMOD, TCON, SCON, and PCON
contain control and status bits for the interrupt system, the
Timer/Counters, and the serial port. They are described in later
sections.
Basic Registers:-
A number of 8052 registers can be considered "basic." Very little can be
done without them and a detailed explanation of each one is warranted
to make sure the reader understands these registers before getting into
more complicated areas of development.
The Accumulator:-
If you've worked with any other assembly language you will be familiar
with the concept of an accumulator register.
The Accumulator, as its name suggests, is used as a general register to
accumulate the results of a large number of instructions. It can hold an
8-bit (1-byte) value and is the most versatile register the 8052 has due
to the sheer number of instructions that make use of the accumulator.
More than half of the 8052's 255 instructions manipulate or use the
Accumulator in some way.
For example, if you want to add the number 10 and 20, the resulting 30
will be stored in the Accumulator. Once you have a value in the
Accumulator you may continue processing the value or you may store it
in another register or in memory.
The "R" Registers:-
The "R" registers are sets of eight registers that are named R0, R1,
through R7. These registers are used as auxiliary registers in many
operations. To continue with the above example, perhaps you are
adding 10 and 20. The original number 10 may be stored in the
Accumulator whereas the value 20 may be stored in, say, register R4.
To process the addition you would execute the command:
               ADD A, R4
After executing this instruction the Accumulator will contain the value
30. You may think of the "R" registers as very important auxiliary, or
"helper", registers. The Accumulator alone would not be very useful if it
were not for these "R" registers.
The "R" registers are also used to store values temporarily. For
example, let’s say you want to add the values in R1 and R2 together and
then subtract the values of R3 and R4. One way to do this would be:
       MOV A, R3               ; Move the value of R3 to accumulator
       ADD A, R4                ; add the value of R4
       MOV R5, A               ; Store the result in R5
       MOV A, R1              ; Move the value of R1 to Acc
       ADD A, R2                ; add the value of R2 with A
       SUBB A, R5              ; Subtract the R5 (which has R3+R4)
As you can see, we used R5 to temporarily hold the sum of R3 and R4.
Of course, this isn't the most efficient way to calculate (R1+R2) - (R3
+R4) but it does illustrate the use of the "R" registers as a way to store
values temporarily.
As mentioned earlier, there are four sets of "R" registers-register bank
0, 1, 2, and 3. When the 8052 is first powered up, register bank 0
(addresses 00h through 07h) is used by default. In this case, for
example, R4 is the same as Internal RAM address 04h. However, your
program may instruct the 8052 to use one of the alternate register
banks; i.e., register banks 1, 2, or 3. In this case, R4 will no longer be the
same as Internal RAM address 04h. For example, if your program
instructs the 8052 to use register bank 1, register R4 will now be
synonymous with Internal RAM address 0Ch. If you select register bank
2, R4 is synonymous with 14h, and if you select register bank 3 it is
synonymous with address 1Ch.
The concept of register banks adds a great level of flexibility to the
8052, especially when dealing with interrupts (we'll talk about
interrupts later). However, always remember that the register banks
really reside in the first 32 bytes of Internal RAM.
The B Register:-
The "B" register is very similar to the Accumulator in the sense that it
may hold an 8-bit (1-byte) value. The "B" register is only used implicitly
by two 8052 instructions: MUL AB and DIV AB. Thus, if you want to
quickly and easily multiply or divide A by another number, you may
store the other number in "B" and make use of these two instructions.
Aside from the MUL and DIV instructions, the "B" register are
often used as yet another temporary storage register much like a ninth
"R" register.
The Program Counter:-
The Program Counter (PC) is a 2-byte address that tells the 8052 where
the next instruction to execute is found in memory. When the 8052 is
initialized PC always starts at 0000h and is incremented each time an
instruction is executed. It is important to note that PC isn't always
incremented by one. Since some instructions are 2 or 3 bytes in length
the PC will be incremented by 2 or 3 in these cases.
The Program Counter is special in that there is no way to directly
modify its value. That is to say, you can't do something like PC=2430h.
On the other hand, if you execute LJMP 2430h you've effectively
accomplished the same thing.
It is also interesting to note that while you may change the value of PC
(by executing a jump instruction, etc.) there is no way to read the value
of PC. That is to say, there is no way to ask the 8052 "What address are
you about to execute?" As it turns out, this is not completely true:
There is one trick that may be used to determine the current value of
PC. This trick will be covered in a later chapter.
The Data Pointer:-
The Data Pointer (DPTR) is the 8052ís only user-accessible 16-bit (2-
byte) register. The Accumulator, "R" registers, and "B" register are all 1-
byte values. The PC just described is a 16-bit value but isn't directly
user-accessible as a working register.
DPTR, as the name suggests, is used to point to data. It is used by a
number of commands that allow the 8052 to access external memory.
When the 8052 accesses external memory it accesses the memory at
the address indicated by DPTR.
While DPTR is most often used to point to data in external memory or
code memory, many developers take advantage of the fact that it's the
only true 16-bit register available. It is often used to store 2-byte values
that have nothing to do with memory locations.
The Stack Pointer:-
The Stack Pointer, like all registers except DPTR and PC, may hold an 8-
bit (1-byte) value. The Stack Pointer is used to indicate where the next
value to be removed from the stack should be taken from.
When you push a value onto the stack, the 8052 first increments the
value of SP and then stores the value at the resulting memory location.
When you pop a value off the stack, the 8052 returns the value from
the memory location indicated by SP, and then decrements the value of
SP.This order of operation is important. When the 8052 is initialized SP
will be initialized to 07h. If you immediately push a value onto the
stack, the value will be stored in Internal RAM address 08h. This makes
sense taking into account what was mentioned two paragraphs above:
First the 8051 will increment the value of SP (from 07h to 08h) and then
will store the pushed value at that memory address (08h).
Addressing Modes:-
The addressing modes in the 80C51 instruction set are as follows:
Direct Addressing:-
In direct addressing the operand is specified by an 8-bit address field in
the instruction. Only internal Data RAM and SFRs can be directly
addressed.
Indirect Addressing:-
In indirect addressing the instruction specifies a register which contains
the address of the operand. Both internal and external RAM can be
indirectly addressed. The address register for 8-bit addresses can be R0
or R1 of the selected bank, or the Stack Pointer. The address register
for 16-bit addresses can only be the 16-bit “data pointer” register,
DPTR.
Register Instructions:-
The register banks, containing registers R0 through R7, can be accessed
by certain instructions which carry a 3-bit register specification within
the opcode of the instruction. Instructions that access the registers this
way are code efficient, since this mode eliminates an address byte.
When the instruction is executed, one of the eight registers in the
selected bank is accessed. One of four banks is selected at execution
time by the two bank select bits in the PSW.
Register-Specific Instructions:-
Some instructions are specific to a certain register. For example, some
instructions always operate on the Accumulator, or Data Pointer, etc.,
so no address byte is needed to point to it. The opcode itself does that.
Instructions that refer to the Accumulator as A assemble as
accumulator specific opcodes.
Immediate Constants:-
The value of a constant can follow the opcode in Program Memory.
For example,
MOV A, #100
Loads the Accumulator with the decimal number 100. The same
number could be specified in hex digits as 64H.
Indexed Addressing:-
Only program Memory can be accessed with indexed addressing, and it
can only be read. This addressing mode is intended for reading look-up
tables in Program Memory A 16-bit base register (either DPTR or the
Program Counter) points to the base of the table, and the Accumulator
is set up with the table entry number. The address of the table entry in
Program Memory is formed by adding the Accumulator data to the
base pointer. Another type of indexed addressing is used in the “case
jump” instruction. In this case the destination address of a jump
instruction is computed as the sum of the base pointer and the
Accumulator data.
What is L.C.D.?
It is a liquid crystal display of thin flat panel used for electronically
displaying information such as text, images and moving pictures.

Example: Display the monitor of CPU.

Ranging from aircraft cockpit display.

Television.
LCD DISPLAY IMAGE GRAFITTE
PIN DIAGRAM OF L.C.D.

L.C.D.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Vss Vcc Vee RS R/W E DB0 DB1DB2 DB3DB4 DB5 DB6 DB7 LED+ LED-

PIN No. SYMBOL I/O DISCRIPTION

1 Vss -- GROUNDED

2 Vcc -- +5V POWER SUPPLY

3 Vee -- Power supply to control contrast

4 RS I RS=0,select command register

RS=1,select data register

5 R/W I R/W=0,for write

R/W=1,for read

6 E I/O Enable

7-14 DB0 I/O The 8 bit data bus


Interfacing of LCD with 8051 Microcontroller

10K
POT
Circuit Diagram for displaying ’SPICE’
GROUND
Regulator
+5V

12 V
D.C. Voltag e

L.C.D.
Vss Vcc Vee RS R/W E DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 LED+ LED-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

POT 10.0k

33.0p

33.0p
10.0k

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
P1.O P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 R ST P3.0 P3.1 P3.2 P3.3 P3.4 P3.5 P3.6 P3.7 XTALT2 XTAL1 GN D

8051 MCU
Vc c P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 P0.7 EA / VppALE PSEN P2.7 P2.6 P2.5 P2.4 P2.3 P2.2 P2.1 P2.0
P0.0
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21

10.0k 10.0k 10.0k 10.0k 10.0k 10.0k 10.0k 10.0k

5.0
S1 S2 S3 S4
100.0
100.0
100.0

100.0

100.0
100.0

100.0

100.0
led 1N1183
led 1N1183

led 1N1183

led 1N1183

led 1N1183

led 1N1183

led 1N1183

led 1N1183

10.0k

10.0k

10.0k

10.0k

Circuit Description
In this interfacing we use the port 3 as a LCD control and port 1 as a LCD
data. Switches connected on port 3 and LED connected on port 1.
Whenever we use port 0 we have to connect pull up register externally
to make it by directional because of by default port 0 is unidirectional
i.e. only input port .

All other ports have already inbuilt pull up register so no need to


connect pull up register externally.

CONNECTION OF PULLUP REGISTER

Vcc
10
K
P0.0
P0.1 Port 0
P0.2
P0.3
8051 P0. 4
P0.5
MCU P0.6
P0.7
Port 0 is also designated as AD0 –AD7 allowing it to be used for both
address and data when connection and 8051 to an external memory
port 0 provides both address and data .The 8051 multiplexes address
and data through port 0 to save pins.

ALE indicates if port 0 as address or data .When ALE=0 it provides data


D0-D7 but when ALE=1 it has address A0-A7.Therefore ALE is used for
demultiplexing address and data with the help of a 74LS 373 latch. In
8051 based system where there is no external memory connection, the
pins of port 0 must be connected externally to a 10k ohm pull-up
register. This is due to fact that port 0 each and opens drain, unlike
port1, port2 and port3.
The 8051 has on chip oscillator but requires an external clock to run it.
Most often a quartz crystal oscillator is connected to inputs XTAL1 and
XTAL2. The quartz crystal oscillator connected to XTAL1 and XTAL2
also needs two capacitor of 30pF value. One side of each capacitor is
connected to the ground

List of hardware.
S.NO. Name of Hardware. Quantity
1. 40 pin IC base 1
2. 8051 p89B51RD2FN MCU 1
3. XTAL(11.0592Mhz) 1
4. Capacitor 30pF 2
5. 10k POT 1
6. LCD 1
7. 7085 regulator 1
8. Pull-up resistor 1
9. G.P. PCB 1
10. Berg strip As required.
11. LED 8
12. Wires As required
13. Resistance As required
14. Multimeter
15. 12v DC supply source 1
16. Soldering wires, soldering iron ,Flux

LCD Commands Codes


Code(HEX) Command to LCD Instruction Register
1 Clear Display Screen.
2 Return Home.
4 Decrement cursor( shift cursor to left)
6 Increment cursor( shift cursor to lift)
5 Shift display right
7 Shift display left
8 Display off, cursor off
A Display off, cursor on
C Dicplay on, cursor off
E Display on, cursor blinking
F Display on, cursor blinking
10 Shift cursorposition to left
14 Shift cursor position to right
18 Shift the entire display to the left
1C Shift to the entire display to the right
80 Force cursor to beginning of first line
C0 Force cursor to beginning of second
line
38 2 lines and 5*7 matrix
Coding of scrolling bouncing

 #include<reg51.h>

 sbit rs=P3^0; //rs is connected to first pin of port-3//

 sbit e=P3^1; //e is connected to second pin of port-


3//

 sbit s1=P2^0; //switch s1 is connected to first pin of


port-2//

 sbit s2=P2^1; //switch s1 is connected to second

 pin of port-2//

• bit s3=P2^2; //switch s1 is connected to third pin of port-


2//

 sbit s4=P2^3; //switch s1 is connected to forth pin of


port-2//

 char a[]={'S','P','I','C','E'}; //five character string to


be display//
 char l,m, k;

 void comddisply() //for command function//

{

rs=0;

//for selecting command register //

 e=1; //enable the l.c.d.//

 e=0;

 void datadisply() // for data function//

 rs=1; //for selecting data register//

 e=1; //enable the l.c.d.//

 e=0;

}

 void delay() //for delay function//

{

 int i,j;

 for(i=0;i<10;i++)

 for(j=0;j<5000;j++);

}
 void main()

{

 s1=0;

 s2=0;

 s3=0;

 s4=0;

 bond: //define fuction bond// P2=0x00; //disabled all


switches//

 //FOR SCROLLING //

 while(1) //for infinite loop//

{

 if(s1==1) //selecting switch s1//

{

 while(1)

{

 int k,l;

 P1=0x38; //for initialize the lcd//


 comddisply(); //calling command function//

 delay(); //calling delay function//

 P1=0x0e; //for display on//

 comddisply();

 delay();

 P1=0x06; //for cursor on//

 comddisply();

 delay();

 P1=0x01; //for clear screen//

 comddisply();

 delay();

 P1=0x80; //go for first of first row first position//

 comddisply();

 delay();

 if(s4==1) //for exit from infinite loop//

{

 goto bond; //go to bond//

}

 for(k=0;k<=4;k++)
 {

 P1=a[k];

 datadisply();

 delay();

 }

 for(l=0;l<=15;l++)

 {

 P1=0x1c; //for shift entire display to right side//

 comddisply();

 delay();

 }

}

}

//FOR BOUNCING//
 if(s2==1)

{

 P1=0x38;

 comddisply();

 delay();
 P1=0x0e;

 comddisply();

 delay();

 P1=0x06;

 comddisply();

 delay();

 P1=0x80;

 comddisply();

 delay();

 for(k=0;k<=4;k++)

{

 P1=a[k];

 datadisply();

 delay();

}

 while(1)

{

 if(s4==1)

{

 goto bond;
}

 for(l=1;l<=11;l++)

{

 P1=0x1c;

 comddisply();

 delay();

}

 for(m=11;m>=1;m--)

{

 P1=0x18; //for shift entire display to right side//

 comddisply();

 delay();

}

}

}

 //FOR GLOWING LEDS//


 if(s3==1)

{

 while(1)
{

 int a;

 P0=0x80; //for forced cursor to beginning to first line//

 delay();

 if(s4==1)

{

 goto bond;

}

 for(a=0;a<=7;a++)

{

 P0=P0>>1; // shift operator for increament in position of


cursor//

 delay();

}

}

}

}
CONCLUSION:-
Knowing about the microcontroller has always been the matter of
excitement for all of us. And summer training during the June 2009 was
the one of the good opportunity to fulfill this. The training was as
fruitful as expected.

There we got the exposure about the 8051 microcontroller and its
various basic electronics components used in developing an embedded
system. We worked on keil tool software which is used to developed
program for embedded system. The work experience in the
Advanced Technology was quite nice. The trainers those were assigned
to us were quite experience

You might also like