Beruflich Dokumente
Kultur Dokumente
1. SYNOPSIS
2. BLOCK DIAGRAM
TRANSFORME
R
RECTIFIER
REGULATOR
ZIF SOCKET
RESET
CIRCUIT
OSCILLATOR
CIRCUIT
MICROCONTROLLER
8051
LCD DRIVER
LCD
MATRIX KEYPAD
3. 8051
After reset, the CPU begins execution from address location 0000
of the program memory.
Data memory is the Read/Write memory. Hence, it can be both read from
and written into 8051 has got 128 bytes of internal data memory and 64k of
external data memory.
Internal data memory addresses are one byte wide which includes
128 bytes of on-chip RAM plus a number of special function registers. The 128
bytes of RAM can be accessed either by direct addressing or by indirect
addressing.
There can be upto 64k bytes of data memory external to the chip.
External data memory addresses can be either 1 or 2 bytes wide depending on the
addressing mode. The MOVX instruction can be used to access the external data
memory.
a) PARALLEL PORT:
8051 has four 8-bit parallel ports. All four parallel ports are bidirectional. Each line consists of a latch, an output driver and an input buffer.
The four ports are named as port 0 (p0), port 1(p1), port 2(p2) and
port 3 (p3a). they are bit addressable and has to be represented in the form PX, Y
i.e. bit Y of port X while using bit addressing mode. PX.0 is the LSB (Least
Significant Bit) of port X and PX.7 is the MSB (Most significant bit) of that port.
Out of the four ports, port 0 and port 2 are used in accesses to
external memory. All the port 3 pins are multifunctional. They are not only port
pins, but also serve the functions of various special features as listed in Table-1.
The output drivers of port 0 and port 2 and the input buffers of port
0 are used in accesses to external memory, 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, port 2 pins continue to emit the p2 SFR content.
Port pin
Alternate Function
P3.0
P3.1
P3.2
P3.3
P3.4
T0 (Timer/counter 0 external
P3.5
P3.6
input)
T1 (Timer/counter 1 external
input)
WR (External data memory
P3.7
write strobe)
RD (External data memory
read strobe)
NOTE:
For the complete details of various registers mentioned in the following
sections, please refer to the section Registers of 8051 of this chapter.
b) TIMER/COUNTERS:
8051 has two 126-bit timer/counters namely Timer / counter 0 and timer /
counter 1. they can be configured in any of the four operating modes, which are
selected by bit modes 0,1 and 2 are the same for both the timer/counters. Mode 3 is
different.
MODE 0:
The 12-bit register consists of all 8 bits of TH1 and the lower 5 bits of TL1
and the lower 5 bits of TL1. the upper 3 bits of TL1 are indeterminate and should
be ignored. Setting the run flag TR1 does not clear the registers.
MODE 2:
Mode 1 is the same as mode 0, except that the timer register is being run
with all 16 bits.
MODE 2:
MODE 3:
Timer 1 in mode 3 simply holds its count. The effect is the same as setting
TR1 =0. Timer 0 in mode 3 establishes TL0 and TH0 as two separate counters.
c) SERIAL PORT:
The 8051 has a full Duplex Serial Port, meaning it can transmit and receive
simultaneously received byte has been read from the receive register. The serial
port receive and transmit registers are both accessed at special function register
SBUF (Serial data Buffer). Writing to SUBF loads the transmit register. The serial
port of 8051 can be employed in four modes, the details of which are presented
below.
MODE 0:
Mode 0 has a fixed baud rate which is 1/12 of the crystal oscillator
frequency. To run the serial port in this mode, one of the timer/counters need to be
set up only the SCON register needs to be defined.
Serial data enters and exists through RxD (Receive data). Tx D (Transmit
Data) outputs the shift clock. 8 bits are transmitted/received with LSB taking the
leading position.
MODE 1:
10 bits are transmitted or received: a start bit(0), 8 data bits and a stop bit(1).
On receive, the stop bit goes into RB8 in special function register SCON. The
Baud rate is variable. The baud rate can be generated by timer 0 and timer 1.
MODE 2:
11 bits are transmitted (through TxD) or received (through RxD); a
start bit (0), 8 data bits (LSB), a programmable 9 th data bit and a stop bit (1). on
transmit, the 9th data bit can be assigned the value of 0 or 1. or, for example, the
parity bit goes into RB8 in the special function registers SCON, while the stop bit
is ignored. The baud rate is programmable to either 1/32 or 1/64 of the crystal
oscillator frequency.
MODE 3:
NOTE:
Please refer to Chapter 4, for generating baud rates using the on chip timer
of 8051 , to access the onchip serial port in various modes, under the heading
Onchip features of 8051.
The various special function registers available in the internal data memory
8051 are listed in Table 2. The table also indicated whether each one is only byte
addressable or byte and bit addressable (marked with an asterisk *) and the
addresses of those registers (i.e., On-chip RAM address.)
TABLE -2.
SYMBO
L OF
SFR
ADDRESS
*ACC
ACCUMULATOR
E0
*B
B REGISTER
F0
*PSW
D0
SP
STACK POINTER
81
DPTR
DPL
LOW BYTE
82
DPH
HIGH BYTE
83
*P0
PORT 0
80
*P1
PORT 1
90
*P2
PORT 2
A0
*P3
PORT 3
B0
*IP
INTERRUPT PRIORITY
CONTROL
B8
*IE
TMOD
*TCON
INTERRUPT ENABLE
CONTROL
TIMER/COUNTER MODE
CONTROL
TIMER/COUNTER CONTROL
A8
89
88
TABLE-2
SYMBO
NAME
ADDRESS
TIMER/COUNTER 0 HIGH
8C
L
TH0
TL0
TH1
TL1
BYTE
TIMER/COUNTER 0 LOW
BYTE
TIMER/COUNTER 1 HIGH
8D
8B
*SCON
BYTE
98
SBUF
TIMER/COUNTER 1 LOW
99
PCON
BYTE
87
SERIAL CONTROL
SERIAL DATA BUFFER
POWER CONTROL
8A
Bit Addressable.
3.8. ACCUMULATOR:
ACC is the Accumulator register, The mnemonics for AccumulatorSpecific instructions, however refer to the Accumulator as simply A. Accumulator
is an important Register on which various special operations such as reading from
or writing to an external memory , rotation , addition, subtraction, multiplication,
division and various other operations can be done.
B REGISTER
The PSW register contains several status bits that reflect the current state
of the CPU. It contains the carry bit, the Auxillary carry bit, two register bank
select bits, the over flow flag, the parity bit and two user-definable status flags.
This register is bit addressable.
D7
CY
D6
AC
D5
F0
D4
D3
RS1
RS0
D2
OV
D1
-
D0
P
CY
PSW.7
Carry Flag
AC
PSW.6
F0
PSW.5
RS1
PSW.4
RS0
PSW.3
OV
PSW.2
PSW.1
PSW.0
NOTE:
The value of RS0 and RS1 select the onchip register banks.
RS1
RS0
REGISTER
ADDRESS
BANK
0
00 07
08 0F
10 17
18 1F
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 for external memory access.
It may be manipulated as a 16-bity register or as two independent 8-bit registers.
PORTS 0 TO 3:
Port 0, port 1, port 2 and port 3 are the SFR latches of ports 0, 1, 2 and 3
respectively.
The serial data buffer is actually two separate registers, a transmit buffer and
a receive buffer register when data is written to SUBF, it goes to the transmit buffer
where it is held for serial transmission. When data is read from SBUF, it comes
from the receive buffer.
Register pairs (TH0, TL0), (TH1, TL1) are the 16-bit counting registers for
Timer/counters 0 and 1 respectively.
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.
3.14. PCON: POWER CONTROL REGISTER:
Bit 7 of PCON register is used to control the baud clock generated from
the timer. In the case of 80C51BH, PCON register can be used to select the power
down mode and Idle mode of operation. Please refer to the Intel data sheets of
80C51BH for the complete details of the above said modes. This register is not bit
addressable.
D7
D6
Smod -
D5
D4
D3
D2
D1
D0
GF1
GF0
PD
IDL
SMO - Double baud rate bit. If timer 1 is used to generate baud rate and
SMOD = 1, the baud rate is doubled when the serial port is used in modes 1, 2 or
Bits 4,5,6
- Not implemented, reserved for future use. User software should not
- Power down bit. Setting this bit activates power down operation in
the 80C51BH. In rest of the microcontrollers, PD and IDL bits does not serve any
purpose.
IDL - Idle mode bit. Setting this bit activates Idle mode operation of 80C51BH.
If is are written to PD and IDL at the same time, PD takes precedence.
3.15. IE: INTERRUPT ENABLE REGISTER:
D7
D6
D5
D4
D3
D2
D1
D0
EA
ET2
ES
ET1
EX1
ET0
EX0
setting or
IP register is used to assign the priority for the interrupts of 8051. if the bit is
0, the corresponding interrupt has a lower priority and if the bit is 1, the
corresponding interrupt has a higher priority. Bit addressing is allowed with this
register also.
D7
D6
D5
D4
D3
D2
D1
D0
PT2
PS
PT1
PX1
PT0
PX0
IP.7, IP.6
PT2 IP.5
PS
IP.4
PT1 IP.3
PX1 IP.2
PT0 IP.1
PX0 IP.0
D7
D6
D5
D4
D3
D2
D1
D0
TF1
TR1
TF0
TR0
IE1
IT1
IE0
IT0
TF1 TCON.7
TR1 TCON.6
Timer/Counter 1 ON/OFF.
TF0 TCON.5
TR0 TCON.4
Timer/counter 0 ON/OFF.
IE1
TCON.3
TCON.2
IE0
TCON.1
IT0
TCON.0
D6
C/T*
D5
M1
TIMER 1
D4
M0
D3
D2
GATE C/T*
D1
D0
M1
TIMER 0
GATE- When TRx is set and GATE =1, TIMER/COUNTERx will runonlywhile
INTx
TRx = 1
pin is high. When GATE =0, TIMER/COUNTERx will run only while
C/T* - Timer or counter selector, cleared for timer operation. Set for counter
operation.
M1,M0
SCON register is used to specify the mode in which the serial port is to
work. TI (Transmit interrupt) / RI (Receiver Interrupt) flag(s) of SCON register can
be used to check whether the transmission/reception is over.
D7
D6
D5
D4
D3
D2
D1
SM0
SM1
SM2
REN
TB8
RB8
TI
D0
RI
SM2 SCON.5-
modes 2 &3. in mode 2 or 3, if SM2 is set to 1, then RI will not be activated if the
received 9th data bit (RB8) is0. in mode 1, if SM2 = 1, then RI will not be activated
if a valid stop bit was not received. In mode 0, SM2 should be 0.
REN
SCON.4
TB8
SCON.3
Set/cleared by software.
RB8
SCON.2
received. In mode 1, if SM2 =0, RB8 is the stop bit that was received. In mode 0,
or at the beginning of the stop bit in the other modes. Must be cleared by software.
TI
SCON.1
end of the 8th bit time in mode 0, or at the beginning of the stop bit in the other
modes. Must be cleared by software.
RI
SCON.0
of the 8th bit time in mode 0, or halfway through the stop bit time in the other
modes. Must be cleared by software.
Immediate
Direct
Indirect
Register
Register specific
Indexed
MOVX
@DPTR,A
Writes the contents of the accumulator to the address held by the DPTR register.
3.23. REGISTER ADDRESSING:
When the instruction is executed, one of the eight registers in the selected
bank is accessed. One of the four banks is selected at the execution time by the two
bank select bits in the PSW. For example, the instruction, MOV A,R0Copies
the
RR
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 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. The
instruction, MOV A,@A+DPTRReads the contents of program memory, whose
address is obtained by adding the contents of DPTR and accumulator and copies it
to the accumulator.
This manual is formulated as a user manual common for both Micro-51 and
Micro power-I based 8031/8051 piggyback boards. Since almost all the features
are common for both the kits, the worked out examples given in chapters 2, 3 and 4
will work in both the kits. But, the peripherals addresses will differ.
Having this in mind, the addresses of all the peripherals provided in both
the kits are tabulated in table-3 and are given a general name. In the worked out
examples, only these general names are mentioned. The user has to substitute the
correct address depending on the kit in which the user is working.
TABLE 3:
NAME OF THE
ADDRESS IN
ADDRESS
GENERAL
PERIPHERAL
Micropower-i
IN Micro-51
NAME
A000
E000
DSP_DAT
8279 CONTROL
A001
E001
DSP_CNT
A004
E008
TMR_CH0
A005
E009
TMR_CH1
A006
E00A
TMR_CH2
A007
E00B
TMR_CNT
A008
E004
SER_DAT
A009
E005
SER_CNT
A00C
E00C
APORT_1
A00D
E00D
BPORT_1
A00E
E00E
CPORT_1
A00F
E00F
CNT_1
A010
E010
APORT_2
A011
E011
BPORT_2
A012
E012
CPORT_2
A013
E013
CNT_2
E014
APORT_3
E015
BPORT_3
E016
CPORT_3
E017
CNT_3
A014
E01C
TPE_WR
A018
ICW1
PORT
8253 CHANNEL 0
8253 CHANNEL 1
8253 CHANNEL 2
8253 CONTROL
8251 DATA PORT
8251 CONTROL
PORT
8255-1 PORT A
8255-1 PORT B
8255-1 PORT C
8255-1 CONTROL
8255-2 PORT A
8255-2 PORT B
8255-2 PORT C
8255-2 CONTROL
8255-3 PORT A
8255-2 PORT B
8255-2 PORT C
8255-2 CONTROL
CHAPTER 2
SOFTWARE EXAMPLES
4. KEY PAD
i)
ii)
iii)
Coded keyboard
The lead per key configuration is typically used when there are very
few keys to be sensed. Since each key could tie up a port pin, it is suggested
that the number be kept to 16 or fewer for this keyboard type. This
configuration is the most costs effective for a small number of keys.
The X-Y matrix connections are very popular when the number of keys
exceeds 10.
5. LCD DISPLAY
5.1. INTRODUCTION:
Liquid crystal displays (LCDs) have materials which combine the
properties of both liquids and crystals. Rather than having a melting point, they
have a temperature range within which the molecules are almost as mobile as they
would be in a liquid, but are grouped together in an ordered form similar to a
crystal.
An LCD consists of two glass panels, with the liquid crystal material sand
witched in between them. The inner surface of the glass plates are coated with
transparent electrodes which define the character, symbols or patterns to be
displayed polymeric layers are present in between the electrodes and the liquid
crystal, which makes the liquid crystal molecules to maintain a defined orientation
angle.
One each polarisers are pasted outside the two glass panels. These
polarisers would rotate the light rays passing through them to a definite angle, in a
particular direction
When the LCD is in the off state, light rays are rotated by the two polarisers
and the liquid crystal, such that the light rays come out of the LCD without any
orientation, and hence the LCD appears transparent.
When sufficient voltage is applied to the electrodes, the liquid crystal
molecules would be aligned in a specific direction. The light rays passing through
the LCD would be rotated by the polarisers, which would result in activating /
highlighting the desired characters.
The LCDs are lightweight with only a few millimeters thickness. Since the
LCDs consume less power, they are compatible with low power electronic
circuits, and can be powered for long durations.
The LCDs doing generate light and so light is needed to read the display. By
using backlighting, reading is possible in the dark. The LCDs have long life and a
wide operating temperature range.
Changing the display size or the layout size is relatively simple which makes
the LCDs more customer friendly.
5.3. HARDWARE:
Utilize the Hosts extended timing mode, if available, when transacting with
the module. Use instructions, which prolong the Read and Write or other
appropriate data strobes, so as to realize the interface timing requirements.
If a parallel port is used to drive the RS, R/W and E control lines, setting
the E bit simultaneously with RS and R/W would violate the modules set up
time. A separate instruction should be used to achieve proper interfacing timing
requirements.
5.4. MOUNTING:
Cover the display surface with a transparent protective plate, to protect the
polarizer. Dont touch the display surface with bare hands or any hard materials.
This will stain the display area and degrade the insulation between terminals.
Do not use organic solvents to clean the display panel as these may
adversely affect tape or with absorbant cotton and petroleum benzene.
The
processing or even a slight deformation of the claws of the metal frame will have
effect on the connection of the output signal and cause an abnormal display.
Do not damage or modify the pattern wiring, or drill attachment holes in the
PCB. When assembling the module into another equipment, the space between the
module and the fitting plate should have enough height, to avoid causing stress to
the module surface.
Make sure that there is enough space behind the module, to dissipate the
heat generated by the ICs while functioning for longer durations. When an
electrically powered screwdriver is used to install the module, ground it properly.
While cleaning by a vacuum cleaner, do not bring the sucking mouth near
the module. Static electricity of the electrically powered driver or the vacuum
cleaner may destroy the module.
Operate the LCD module under the relative condition of 40C and 50%
relative humidity. Lower temperature can cause retardation of the blinking speed of
the display, while higher temperature makes the overall display discolor.
When the temperature gets to be within the normal limits, the display will
be normal. Polarization degradation, bubble generation or polarizer peel-off may
occur with high temperature and humidity.
Contact with water or oil over a long period of time may cause deformation
or colour fading of the display. Condensation on the terminals can cause electrochemical reaction disrupting the terminal circuit.
When the power supply is given to the module, with the pin 3 (VL)
connected to ground, all the pixels of a character gets activated in the following
manner:
The
first
eight characters of a single line display, operated in the two-line display mode, as
in CDM 16116.
If the above mentioned does not occur, the module should be initialized by
software. Make sure that the control signals E , R/W and RS are according to the
interface timing requirements.
When the characters to be displayed are missing between, the data read/write
is too fast. A slower interfacing frequency would rectify the problem.
When uncertainty is there in the start of the first characters other than the
specified ones are rewritten, check the initialization and the software routine.
If
particular pixels of the characters are missing, or not getting activated properly,
there could be an assembling problem in the module.
INTRODUCTION:
REGISTERS:
The controller IC has two 8 bit registers, an instruction register (IR) and a
data register (DR). The IR stores the instruction codes and address information for
display data RAM (DD RAM) and character generator RAM (CG RAM). The IR
can be written, but not read by the MPU.
Similarly, for the MPU write of the DR, the next DD RAM or CG RAM address is
selected for the write operation.
RS
R/W
Operation
or CG RAM to DR)
When the busy flag is1, the controller is in the internal operation mode, and
the next instruction will not be accepted.
When RS = 0 and R/W = 1, the busy flag is output to DB7.
The next instruction must be written after ensuring that the busy flag is 0.
The address counter allocates the address for the DD RAM and CG RAM
read/write operation when the instruction code for DD RAM address or CG RAM
address setting, is input to IR, the address code is transferred from IR to the
address counter. After writing/reading the display data to/from the DD RAM or CG
RAM, the address counter increments/decrements by one the address, as an
internal operation. The data of the address counter is output to DB0 to DB6 while
R/W = 1 and RS = 0.
The characters to be displayed are written into the display data RAM (DD
RAM), in the form of 8 bit character codes present in the character font table. The
extended capacity of the DD RAM is 80 x 8 bits i.e. 80 characters.
5.14. CHARATCER GENERATOR ROM (CG ROM)
In the character generator RAM, the user can rewrite character patterns by
program. For 5 x 8 dots, eight character patterns can be written, and for 5 x 10
dots, four character patterns can be written.
When the host processor is so fast that the strobes are too narrow to serve as
the E pulse
6. TRANSFORMER
a. Action:
A transformer changes (transforms) an alternating voltage from one value
to another. It consists of two coils, called the primary and secondary winding,
which are not connected electrically. The windings are either one on top of the
other or are side by side on an iron, iron-dust or air core.
A transformer works by electromagnetic induction: a.c. is supplied to
the primary and produces a changing (alternating) voltage in the secondary. It is
important that as much as possible of the magnetic field produced by the primary
passes through the secondary. A practical arrangement designed to achieve this in
an iron-cored transformer. In which the secondary is wound on top of the primary.
You should also notice that the induced voltage in the secondary is always of
opposite polarity to the primary voltage.
(reduce by laminations), and the magnetic field of the primary not passing entirely
through the secondary.
b. Types of Transformers:
Mains:
Mains transformers are used at a.c. mains frequency (50 Hz
Britain), their primary coil being connected to the 240 V a.c. supply. Their
secondary windings may be step-up or step-down or they may have one or more of
each. They have laminated iron cores and are used in power supply units.
Sometimes the secondary has a center-tap-sec Units 20.2.
Step-down toroidal types are becoming popular. They have
virtually no external magnetic field and a screen between primary and secondary
windings gives safety and electrostatic screening. Their pin connections are
brought out to a 0.1-inch grid, which makes them ideal for printed circuit board
(p.c.b.) mounting.
Isolating transformers have a one-to-one turns ratio (i.e. n s/np =
1/1) and are safety devices for separating a piece of equipment from the mains
supply. They do not change the voltage.
Audio frequency:
Audio frequency transformers, as illustrated in also have laminated iron
cores and are used as output matching transformers to ensure the maximum
transfer of power from the a.f. output stage to the loudspeaker in, for
example, a radio set or amplifier.
Radio frequency:
Radio frequency transformers usually have adjustable iron-dust cores and
form part of the tuning circuits in a radio. They are enclosed in a small
aluminum screening can to stop them radiating energy to other parts of the
circuit.
7. ADVANTAGES
8. APPLICATION
* Automobile Applications
* Home Appliances
* Object Counter
* Electricity Board Applications