You are on page 1of 27

AT89s52 Microcontroller:

Features:

 Compatible with MCS®-51 Products


 8K Bytes of In-System Programmable (ISP) Flash Memory –
Endurance: 1000 Write/Erase Cycles
 4.0V to 5.5V Operating Range
 Fully Static Operation: 0 Hz to 33 MHz
 Three-level Program Memory Lock
 256 x 8-bit Internal RAM
 32 Programmable I/O Lines
 Three 16-bit Timer/Counters
 Eight Interrupt Sources
 Full Duplex UART Serial Channel
 Low-power Idle and Power-down Modes
 Interrupt Recovery from Power-down Mode
 Watchdog Timer
 Dual Data Pointer
 Power-off Flag
 Fast Programming Time
 Flexible ISP Programming (Byte and Page Mode)
 Green (Pb/Halide-free) Packaging Option

Description:

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


microcontroller with 8K bytes of in-system programmable Flash
memory. The device is manufactured using Atmel’s high-density
nonvolatile memory technology and is compatible with the Indus-
try-standard 80C51 instruction set and pin out. The on-chip Flash
allows the program memory to be reprogrammed in-system or by
a conventional nonvolatile memory pro-grammer. By combining a
versatile 8-bit CPU with in-system programmable Flash on a
monolithic chip, the Atmel AT89S52 is a powerful microcontroller
which provides a highly-flexible and cost-effective solution to
many embedded control applications. The AT89S52 provides the
following standard features: 8K bytes of Flash, 256 bytes of RAM,
32 I/O lines, Watchdog timer, two data pointers, three 16-bit
timer/counters, a six-vector two-level interrupt architecture, a full
duplex serial port, on-chip oscillator, and clock circuitry. In
addition, the AT89S52 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 con-
tents but freezes the oscillator, disabling all other chip functions
until the next interrupt or hardware reset.
Pin Description

VCC Supply voltage.


GND Ground.

Port 0

Port 0 is an 8-bit open drain bidirectional I/O port. As an


output port, each pin can sink eight TTL inputs. When 1s are
written to port 0 pins, the pins can be used as high-impedance
inputs. Port 0 can also be configured to be the multiplexed low-
order address/data bus during accesses to external program and
data memory. In this mode, P0 has internal pull-ups. Port 0 also
receives the code bytes during Flash programming and outputs
the code bytes during program verification. External pull-ups
are required during program verification.

Port 1

Port 1 is an 8-bit bidirectional I/O port with internal pull-ups.


The Port 1 output buffers can sink/source four TTL inputs. When 1s
are written to Port 1 pins, they are pulled high by the inter-nal pull-
ups and can be used as inputs. As inputs, Port 1 pins that are
externally being pulled low will source current (IIL) because of the
internal pull-ups. In addition, P1.0 and P1.1 can be configured to
be the timer/counter 2 external count input (P1.0/T2) and the
timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown
in the following table. Port 1 also receives the low-order address
bytes during Flash programming and verification.
Port 2

Port 2 is an 8-bit bidirectional I/O port with internal pull-ups.


The Port 2 output buffers can sink/source four TTL inputs. When 1s
are written to Port 2 pins, they are pulled high by the internal pull-
ups and can be used as inputs. As inputs, Port 2 pins that are
externally being pulled low will source current (IIL) because of the
internal pull-ups. Port 2 emits the high-order address byte during
fetches from external program memory and during accesses to
external data memory that uses 16-bit addresses (MOVX @ DPTR).
In this application, Port 2 uses strong internal pull-ups when
emitting 1s. During accesses to external data memory that uses 8-
bit addresses (MOVX @ RI), Port 2 emits the contents of the P2
Special Function Register. Port 2 also receives the high-order
address bits and some control signals during Flash programming
and verification. Port Pin Alternate Functions P1.0 T2 (external
count input to Timer/Counter 2), clock-out P1.1 T2EX
(Timer/Counter 2 capture/reload trigger and direction control) P1.5
MOSI (used for In-System Programming) P1.6 MISO (used for In-
System Programming) P1.7 SCK (used for In-System Programming)

Port 3

Port 3 is an 8-bit bidirectional I/O port with internal pull-ups.


The Port 3 output buffers can sink/source four TTL inputs. When 1s
are written to Port 3 pins, they are pulled high by the internal pull-
ups and can be used as inputs. As inputs, Port 3 pins that are
externally being pulled low will source current (IIL) because of the
pull-ups. Port 3 receives some control signals for Flash
programming and verification. Port 3 also serves the functions of
various special features of the AT89S52, as shown in the following
table.
RST

Reset input. A high on this pin for two machine cycles while
the oscillator is running resets the device. This pin drives high for
98 oscillator periods after the Watchdog times out. The DISRTO bit
in SFR AUXR (address 8EH) can be used to disable this feature. In
the default state of bit DISRTO, the RESET HIGH out feature is
enabled.

ALE/PROG

Address Latch Enable (ALE) is an output pulse for latching the


low byte of the address during accesses to external memory. This
pin is also the program pulse input (PROG) during Flash
programming. In normal operation, ALE is emitted at a constant
rate of 1/6 the oscillator frequency and may be used for external
timing or clocking purposes. Note, however, that one ALE pulse is
skipped during each access to external data memory. If desired,
ALE operation can be disabled by setting bit 0 of SFR location 8EH.
With the bit set, ALE is active only during a MOVX or MOVC
instruction. Otherwise, the pin is weakly pulled high. Setting the
ALE-disable bit has no effect if the microcontroller is in external
execution mode.
PSEN

Program Store Enable (PSEN) is the read strobe to external


program memory. When the AT89S52 is executing code from
external program memory, PSEN is activated twice each machine
cycle, except that two PSEN activations are skipped during each
access to external data memory.

EA/VPP

External Access Enable. EA must be strapped to GND in order


to enable the device to fetch code from external program memory
locations starting at 0000H up to FFFFH. Note, however, that if
lock bit 1 is programmed, EA will be internally latched on reset. EA
should be strapped to VCC for internal program executions. This
pin also receives the 12-volt programming enable voltage (VPP)
during Flash programming.

XTAL1

Input to the inverting oscillator amplifier and input to the


internal clock operating circuit.

XTAL2

Output from the inverting oscillator amplifier.

Memory Organization

MCS-51 devices have a separate address space for Program


and Data Memory. Up to 64K bytes each of external Program and
Data Memory can be addressed.

Program Memory

If the EA pin is connected to GND, all program fetches are


directed to external memory. On the AT89S52, if EA is connected
to VCC, program fetches to addresses 0000H through 1FFFH are
directed to internal memory and fetches to addresses 2000H
through FFFFH are to external memory.

Data Memory

The AT89S52 implements 256 bytes of on-chip RAM. The


upper 128 bytes occupy a parallel address space to the Special
Function Registers. This means that the upper 128 bytes have the
same addresses as the SFR space but are physically separate from
SFR space. When an instruction accesses an internal location
above address 7FH, the address mode used in the instruction
specifies whether the CPU accesses the upper 128 bytes of RAM or
the SFR space. Instructions which use direct addressing access the
SFR space. For example, the following direct addressing
instruction accesses the SFR at location 0A0H (which is P2). MOV
0A0H, #data Instructions that use indirect addressing access the
upper 128 bytes of RAM. For example, the following indirect
addressing instruction, where R0 contains 0A0H, accesses the
data byte at address 0A0H, rather than P2 (whose address is
0A0H). MOV @R0, #data Note that stack operations are examples
of indirect addressing, so the upper 128 bytes of data RAM are
available as stack space.

Watchdog Timer (One-time Enabled with Reset-out)

The WDT is intended as a recovery method in situations


where the CPU may be subjected to software upsets. The WDT
consists of a 14-bit counter and the Watchdog Timer Reset
(WDTRST) SFR. The WDT is defaulted to disable from exiting reset.
To enable the WDT, a user must write 01EH and 0E1H in sequence
to the WDTRST register (SFR location 0A6H). When the WDT is
enabled, it will increment every machine cycle while the oscillator
is running. The WDT timeout period is dependent on the external
clock frequency. There is no way to disable the WDT except
through reset (either hardware reset or WDT overflow reset).
When WDT over-flows, it will drive an output RESET HIGH pulse at
the RST pin.
Using the WDT

To enable the WDT, a user must write 01EH and 0E1H in


sequence to the WDTRST register (SFR location 0A6H). When the
WDT is enabled, the user needs to service it by writing 01EH and
0E1H to WDTRST to avoid a WDT overflow. The 14-bit counter
overflows when it reaches 16383 (3FFFH), and this will reset the
device. When the WDT is enabled, it will increment every machine
cycle while the oscillator is running. This means the user must
reset the WDT at least every 16383 machine cycles. To reset the
WDT the user must write 01EH and 0E1H to WDTRST. WDTRST is a
write-only register. The WDT counter cannot be read or written.
When WDT overflows, it will generate an output RESET pulse at
the RST pin. The RESET pulse duration is 98xTOSC, where TOSC =
1/FOSC. To make the best use of the WDT, it should be serviced in
those sections of code that will periodically be executed within the
time required to prevent a WDT reset.

WDT during Power-down and Idle

In Power-down mode the oscillator stops, which means the


WDT also stops. While in Power-down mode, the user does not
need to service the WDT. There are two methods of exiting Power-
down mode: by a hardware reset or via a level-activated external
interrupt which is enabled prior to entering Power-down mode.
When Power-down is exited with hardware reset, servicing the
WDT should occur as it normally does whenever the AT89S52 is
reset. Exiting Power-down with an interrupt is significantly
different. The interrupt is held low long enough for the oscillator to
stabilize. When the interrupt is brought high, the interrupt is
serviced. To prevent the WDT from resetting the device while the
interrupt pin is held low, the WDT is not started until the interrupt
is pulled high. It is suggested that the WDT be reset during the
interrupt service for the interrupt used to exit Power-down mode.
To ensure that the WDT does not overflow within a few states of
exiting Power-down, it is best to reset the WDT just before
entering Power-down mode. Before going into the IDLE mode, the
WDIDLE bit in SFR AUXR is used to determine whether the WDT
continues to count if enabled. The WDT keeps counting during
IDLE (WDIDLE bit = 0) as the default state. To prevent the WDT
from resetting the AT89S52 while in IDLE mode, the user should
always set up a timer that will periodically exit IDLE, service the
WDT, and reenter IDLE mode. With WDIDLE bit enabled, the WDT
will stop to count in IDLE mode and resumes the count upon exit
from IDLE.

ADC 0808/0809:

General Description

The ADC0808, ADC0809 data acquisition component is a


monolithic CMOS device with an 8-bit analog-to-digital converter,
8-channel multiplexer and microprocessor compatible control
logic. The 8-bit A/D converter uses successive approximation as
the conversion technique. The converter features a high
impedance chopper stabilized comparator, a 256R voltage divider
with analog switch tree and a successive approximation register.
The 8-channel multiplexer can directly access any of 8-single-
ended analog signals. The device eliminates the need for external
zero and full-scale adjustments. Easy interfacing to
microprocessors is provided by the latched and decoded
multiplexer address inputs and latched TTL TRI-STATE® outputs.
The design of the ADC0808, ADC0809 has been optimized by
incorporating the most desirable aspects of several A/D conversion
techniques. The ADC0808, ADC0809 offers high speed, high
accuracy, minimal temperature dependence, excellent long-term
accuracy and repeatability, and consumes minimal power. These
features make this device ideally suited to applications from
process and machine control to consumer and automotive
applications. For 16-channel multiplexer with common output
(sample/hold port) see ADC0816 data sheet. (See AN-247 for more
information.)

Features

 Easy interface to all microprocessors


 Operates ratio metrically or with 5 VDC or analog span
 Adjusted voltage reference
 No zero or full-scale adjust required
 8-channel multiplexer with address logic
 0V to 5V input range with single 5V power supply
 Outputs meet TTL voltage level specifications
 Standard hermetic or molded 28-pin DIP package
 28-pin molded chip carrier package
 ADC0808 equivalent to MM74C949
 ADC0809 equivalent to MM74C949-1

Key Specifications

 Resolution 8 Bits
 Total Unadjusted Error ±1⁄2 LSB and ±1 LSB
 Single Supply 5 VDC
 Low Power 15 mW
 Conversion Time 100 μs

Block Diagram:

Pin Diagram:
Functional Description:

Multiplexer:

The device contains an 8-channel single-ended analog signal


multiplexer. A particular input channel is selected by using the
address decoder. Table 1 shows the input states for the address
lines to select any channel. The address is latched into the
decoder on the low-to-high transition of the address latch enable
signal.
BUZZER
A buzzer or beeper (BUZZERS)is a signaling device, usually electronic, typically used in automobiles,
household appliances such as a microwave oven, or game shows. It most commonly consists of a number of
switches or sensors connected to a control unit that determines if and which button was pushed or a preset time
has lapsed, and usually illuminates a light on the appropriate button or control panel, and sounds a warning in
the form of a continuous or intermittent buzzing or beeping sound. Initially this device was based on an
electromechanical system which was identical to an electric bell without the metal gong (which makes the
ringing noise). Often these units were anchored to a wall or ceiling and used the ceiling or wall as a sounding
board. Another implementation with some AC-connected devices was to implement a circuit to make the AC
current into a noise loud enough to drive a loudspeaker and hook this circuit up to a cheap 8-ohm speaker.
Nowadays, it is more popular to use a ceramic-based piezoelectric sounder which makes a high-pitched tone.
Usually these were hooked up to "driver" circuits which varied the pitch of the sound or pulsed the sound on
and off.

Features
• Rated Frequency: 3,100Hz
• Operating Voltage: 3 - 20Vdc
• Current Consumption: 14mA @ 12Vdc
• Sound Pressure Level (30cm): 73dB @ 12Vdc
• King State Buzzer - KPE-200
• Dimensions: 22.5mm Diameter, 19mm High, 29mm between mounting holes
MEMS:

Microelectromechanical systems (MEMS) (also written as micro-electro-mechanical,


MicroElectroMechanical or microelectronic and microelectromechanical systems) is the technology of very
small mechanical devices driven by electricity; it merges at the nano-scale into nanoelectromechanical systems
(NEMS) and nanotechnology. MEMS are also referred to as micromachines (in Japan), or Micro Systems
Technology - MST (in Europe).

MEMS are separate and distinct from the hypothetical vision of molecular nanotechnology or molecular
electronics. MEMS are made up of components between 1 to 100 micrometres in size (i.e. 0.001 to 0.1 mm) and
MEMS devices generally range in size from 20 micrometres (20 millionths of a metre) to a millimetre. They
usually consist of a central unit that processes data, the microprocessor and several components that interact
with the outside such as microsensors. At these size scales, the standard constructs of classical physics are not
always useful. Because of the large surface area to volume ratio of MEMS, surface effects such as electrostatics
and wetting dominate volume effects such as inertia or thermal mass.

The potential of very small machines was appreciated before the technology existed that could make
them—see, for example, Richard Feynman's famous 1959 lecture There's Plenty of Room at the Bottom.
MEMS became practical once they could be fabricated using modified semiconductor device fabrication
technologies, normally used to make electronics. These include molding and plating, wet etching (KOH,
TMAH) and dry etching (RIE and DRIE), electro discharge machining (EDM), and other technologies capable
of manufacturing small devices. An early example of a MEMS device is the resonistor – an electromechanical
monolithic resonator.

APPLICATIONS:

In one viewpoint MEMS application is categorized by type of use.

• Sensor
• Actuator
• Structure

In another view point MEMS applications are categorized by the field of application (commercial applications
include):

• Inkjet printers, which use piezoelectrics or thermal bubble ejection to deposit ink on paper.
• Accelerometers in modern cars for a large number of purposes including airbag deployment in
collisions.
• Accelerometers in consumer electronics devices such as game controllers (Nintendo Wii), personal
media players / cell phones (Apple iPhone, various Nokia mobile phone models, various HTC PDA
models) and a number of Digital Cameras (various Canon Digital IXUS models). Also used in PCs to
park the hard disk head when free-fall is detected, to prevent damage and data loss.
• MEMS gyroscopes used in modern cars and other applications to detect yaw; e.g., to deploy a roll over
bar or trigger dynamic stability control
• Silicon pressure sensors e.g., car tire pressure sensors, and disposable blood pressure sensors
• Displays e.g., the DMD chip in a projector based on DLP technology, which has a surface with several
hundred thousand micromirrors
• Optical switching technology, which is used for switching technology and alignment for data
communications
• Bio-MEMS applications in medical and health related technologies from Lab-On-Chip to
MicroTotalAnalysis (biosensor, chemosensor)
• Interferometric modulator display (IMOD) applications in consumer electronics (primarily displays for
mobile devices), used to create interferometric modulation - reflective display technology as found in
mirasol displays

Companies with strong MEMS programs come in many sizes. The larger firms specialize in manufacturing high
volume inexpensive components or packaged solutions for end markets such as automobiles, biomedical, and
electronics. The successful small firms provide value in innovative solutions and absorb the expense of custom
fabrication with high sales margins. In addition, both large and small companies work in R&D to explore
MEMS technology.

POWER SUPPLY:
Power supply is a reference to a source of electrical power. A
device or system that supplies electrical or other types of energy
to an output load or group of loads is called a power supply unit or
PSU. The term is most commonly applied to electrical energy
supplies, less often to mechanical ones, and rarely to others.

A 230v, 50Hz Single phase AC power supply is given to a step


down transformer to get 12v supply. This voltage is converted to
DC voltage using a Bridge Rectifier. The converted pulsating DC
voltage is filtered by a 2200uf capacitor and then given to 7805
voltage regulator to obtain constant 5v supply. This 5v supply is
given to all the components in the circuit. A RC time constant
circuit is added to discharge all the capacitors quickly. To ensure
the power supply a LED is connected for indication purpose.
RELAY

A relay is an electrically operated switch. Current flowing


through the coil of the relay creates a magnetic field which
attracts a lever and changes the switch contacts. The coil current
can be on or off so relays have two switch positions and they are
double throw (changeover) switches.

Relays allow one circuit to switch a second circuit which can


be completely separate from the first. For example a low voltage
battery circuit can use a relay to switch a 230V AC mains circuit.
There is no electrical connection inside the relay between the two
circuits; the link is magnetic and mechanical.

The coil of a relay passes a relatively large current, typically


30mA for a 12V relay, but it can be as much as 100mA for relays
designed to operate from lower voltages. Most ICs (chips) cannot
provide this current and a transistor is usually used to amplify the
small IC current to the larger value required for the relay coil. The
maximum output current for the popular 555 timer IC is 200mA so
these devices can supply relay coils directly without amplification.

Relays are usually SPDT or DPDT but they can have many
more sets of switch contacts, for example relays with 4 sets of
changeover contacts are readily available. For further information
about switch contacts and the terms used to describe them please
see the page on switches.

Most relays are designed for PCB mounting but you can solder
wires directly to the pins providing you take care to avoid melting
the plastic case of the relay.
Advantages of relays:

• Relays can switch AC and DC, transistors can only switch DC.
• Relays can switch high voltages, transistors cannot.
• Relays are a better choice for switching large currents
(> 5A).
• Relays can switch many contacts at once.

Disadvantages of relays:

• Relays are bulkier than transistors for switching small


currents.
• Relays cannot switch rapidly (except reed relays),
transistors can switch many times per second.
• Relays use more power due to the current flowing through
their coil.
• Relays require more current than many ICs can provide,
so a low power transistor may be needed to switch the current
for the relay's coil.
RF TRANSMITTER

In general, the function of a radio frequency (RF) transmitter


is to modulate, up convert, and amplify signals for transmission
into free space. An RF transmitter generally includes a modulator
that modulates an input signal and a radio frequency power
amplifier that is coupled to the modulator to amplify the
modulated input signal. The radio frequency power amplifier is
coupled to an antenna that transmits the amplified modulated
input signal.

Power amplifiers are required in radio telecommunication


systems to amplify signals before transmitting, because a radio
signal attenuates on the radio path. For efficiency, the amplifier is
often a non-linear amplifier operated near its peak capacity. To
avoid distortion of the transmitted signals due to the non-linearity,
the signals are pre-distorted by a predistorter before they are
transmitted.

The predistortion is required to prevent transmitter from


transmitting signals on channel bands other than the band
assigned to the transmitter. Digital predistortion may be
performed by multiplying the modulated signals prepared for
transmission by a set of predistortion values. The predistortion
values are chosen such that the product values entering the power
amplifier will be distorted by the power amplifier to return to a
substantially linear amplification of the modulated signals.

A direct conversion transmitter system to produce a


transmission signal is generally comprised of a low oscillator (LO),
a phase locked loop (PLL), a quadrature generator, a modulator, a
power amplifier (PA), and one or more filters. The low oscillator,
coupled to the PLL, produces a signal with a frequency that is
substantially equal to the frequency of a desired RF transmission
signal. The quadrature generator is coupled to the low oscillator
and the modulator. The PA is coupled to the quadrature generator,
and receives the transmission signal and amplifies it.
The amplified signal may go through a filter to reduce noise or
spurious outputs outside of the transmission band. High quality RF
transmitters typically include band pass filters, such as surface
acoustic wave (SAW) filters provide excellent performance. A
typical cell phone may employ a band pass filter following the
power amplifier to reduce undesired noise present at the antenna
in different portion of RF spectrum to meet various standards'
regulations and specifications.
The optimal functioning of a transmitter in a
telecommunications system depends upon the suitability of the
bandwidth of the transmitted signal to its data rate and
modulation type. Cellular phones are designed to operate within
the environment of one of several mobile communications
networks. Transmitters and receivers for communication systems
generally are designed such that they are tuned to transmit and
receive one of a multiplicity of signals having widely varying
bandwidths and which may fall within a particular frequency
range.
UART

A universal asynchronous receiver/transmitter is a type


of "asynchronous receiver/transmitter", a piece of computer
hardware that translates data between parallel and serial forms.
UARTs are commonly used in conjunction with other
communication standards such as EIA RS-232.

A UART is usually an individual (or part of an) integrated


circuit used for serial communications over a computer or
peripheral device serial port. UARTs are now commonly included in
microcontrollers. A dual UART or DUART combines two UARTs into
a single chip. Many modern ICs now come with a UART that can
also communicate synchronously; these devices are called
USARTs.

The Universal Asynchronous Receiver/Transmitter (UART)


controller is the key component of the serial communications
subsystem of a computer. The UART takes bytes of data and
transmits the individual bits in a sequential fashion. At the
destination, a second UART re-assembles the bits into complete
bytes. Serial transmission of digital information (bits) through a
single wire or other medium is much more cost effective than
parallel transmission through multiple wires. A UART is used to
convert the transmitted information between its sequential and
parallel form at each end of the link. Each UART contains a shift
register which is the fundamental method of conversion between
serial and parallel forms.

MAX232:

The MAX232 is an integrated circuit that converts signals


from an RS-232 serial port to signals suitable for use in TTL
compatible digital logic circuits. The MAX232 is a dual
driver/receiver and typically converts the RX, TX, CTS and RTS
signals.

The drivers provide RS-232 voltage level outputs (approx. ± 7.5 V)


from a single + 5 V supply via on-chip charge pumps and external
capacitors. This makes it useful for implementing RS-232 in
devices that otherwise do not need any voltages outside the 0 V to
+ 5 V range, as power supply design does not need to be made
more complicated just for driving the RS-232 in this case.

The receivers reduce RS-232 inputs (which may be as high as


± 25 V), to standard 5 V TTL levels. These receivers have a typical
threshold of 1.3 V, and a typical hysteresis of 0.5 V.

The later MAX232A is backwards compatible with the original


MAX232 but may operate at higher baud rates and can use
smaller external capacitors – 0.1 μF in place of the 1.0 μF
capacitors used with the original device.

Pin Diagram:

You might also like