KEEP DISTANCE WARNING SYSTEM
CHAPTER 1 INTRODUCTION
Most of the accidents in high-ways are happening due to the drowsiness of drivers, most often this symptom is found in long distance truck drivers, these drivers may take some time to recognize the opposite vehicle, which is running at low speed, resulting accident. This kind of accidents may happen due to the drunken drivers also. So to increase safety an electronic warning system is essential to alert the drivers. This kind of system can be installed in all types of vehicles, especially in commercial vehicles, so that accident rate can be minimized. The warning system designed here can be called as driver attention system, which raises an alarm and energizes the display board automatically when the following vehicle came near to the in-front running vehicle. The system is designed with 89S52 microcontroller, the task is quite simple, the following vehicle detection circuit is designed with infrared sensors, when the IR signal is interrupted due to the following vehicle, the circuit generates high signal and it is fed to microcontroller. It offers several advantages over conventional multi-chip systems. There is a cost and space advantage as extra chip costs and
printed circuit board and connectors required to support multi-chip systems are eliminated.
SOFTWARE REQUIREMENT: 1. KEIL MICRO VISION-3 2. MICRO FLASH HARDWARE REQUIREMENT: 1. MICROCONTROLLER (89S52) 2. LM324. 3. ULTRASONIC SENSOR 4. LCD DISPLAY
DEPT.OF DECS, JNNCE SHIVAMOGGA
KEEP DISTANCE WARNING SYSTEM
The aim of this system is to alert the following vehicle whenever it came very close to the ahead vehicle; thereby to some extent accidents can be avoided .Many accidents at High-ways are taking place due to the close running of vehicles, all of sudden, if the in front vehicle driver reduces the speed or applied breaks, then it is quite difficult to the following vehicle driver to control his vehicle, resulting accidents avoid this kind of accident, the warning system, which contains alarm and display system can arrange at rear side of each and every vehicle.
1.3 BLOCK DIAGRAM:
AT 89S52 MICRO -CONTROLLE R ULTRASONIC SENSOR BUZZER
FIG (1.3) BLOCK DIAGRAM
DEPT.OF DECS, JNNCE SHIVAMOGGA
KEEP DISTANCE WARNING SYSTEM
Hence.4 FLOW CHART:
START Initialization of hardware’s
Initialization of LCD
Initialization of ultrasonic
If object is detected
Object detection is displayed on LCD STOP STOP FIG (1. the controller activates the display board and alarm automatically. logic high signal is generated and it is fed to microcontroller. JNNCE SHIVAMOGGA
. the circuit is designed such that whenever the infrared signal is interrupted.4) FLOWCHART
1.OF DECS. on receipt of this signal.
which is manufactured by ATMEL laboratories. 89S52 has 8KB ROM. There are two other members in the 8051 family of microcontrollers. In addition.KEEP DISTANCE WARNING SYSTEM
CHAPTER 2 DESCRIPTION OF MICROCONTROLLER
DEPT.OF DECS. All the three microcontrollers will have the same internal architecture. 256 bytes of RAM. serial port.1 INTRODUCTION :
The 8051 is an original member of the 8051 family. and interrupt system to continue functioning. and clock circuitry. The Idle Mode stops the CPU while allowing the RAM. The Power down Mode saves the RAM contents but freezes the oscillator. the AT89C52 is a powerful microcomputer which provides a highly flexible and cost effective solution to many embedded control applications. In the concerned project 89S52 microcontroller is used. 89S51 is the most preferable. two timers and 6 interrupts. six-vector two-level interrupt architecture. 8031 has 128 bytes of RAM. 128 bytes of RAM. on-chip oscillator. The Power down Mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset. Microcontroller supports both serial and parallel communication. disabling all other chip functions until the next hardware reset. 128 bytes of RAM. By combining a versatile 8-bit CPU with Flash on a monolithic chip. They are 8052 and 8031. timer/counters. a full duplex serial port. the AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. three timers and 8 interrupts. 89S51 has 4KB ROM. The AT89S52 provides the following standard features: 8Kbytes of Flash. serial port and interrupt system to continue functioning. but they differ in the following aspects. 32 I/O lines. Of the three microcontrollers. two timers and 6 interrupts. The Idle Mode stops the CPU while allowing the RAM. Here microcontroller used is AT89S52. timer/counters. three 16-bit timer/counters. JNNCE SHIVAMOGGA Page 4
. . The transformer output is given to the rectifier circuit.OF DECS.1 INTRODUCTION:
Power supplies are designed to convert high voltage AC mains electricity to a suitable low voltage supply for electronics circuits and other devices.
Fig (3. It is not suitable for electronic circuits unless they include a rectifier and a smoothing capacitor.
DEPT.1) Block Diagram of a Regulated Power Supply System 3.2) Output Waveform of transformer
The low voltage AC output is suitable for lamps. heaters and special AC motors.
Fig( 3.KEEP DISTANCE WARNING SYSTEM
CHAPTER-3 POWER SUPPLY
3. Here we are using a center-tap transformer whose output will be sinusoidal with 24V peak to peak.2 TRANSFORMER:
A transformer steps down high voltage AC mains to low voltage AC.
The Bridge rectifier is a circuit.The conducting diodes D2 and D4 will be in series with the load resistance RL and hence the current flows through RL in the same direction as in the previous half cycle.2) Rectifier output
DEPT. diodes D2 and D4 conduct. The conducting diodes will be in series with the load resistance RL and hence the load current flows through RL.3.KEEP DISTANCE WARNING SYSTEM
3. The circuit has four diodes connected to form a bridge.
FIG (3. JNNCE SHIVAMOGGA
. The ac input voltage is applied to the diagonally opposite ends of the bridge.1) Rectifier circuit
FIG (3. but the DC output is varying.3 RECTIFIER:
A rectifier converts AC to DC.3.For the positive half cycle of the input ac voltage. which converts an ac voltage to dc voltage using both half cycles of the input ac voltage. There are several types of rectifiers. diodes D1 and D3 conduct. Thus a bi-directional wave is converted into unidirectional. here we use a bridge rectifier.OF DECS. The load resistance is connected between the other two ends of the bridge. For the negative half cycle of the input ac voltage.
4 Voltage Regulator:
Voltage Regulator eliminates ripple by setting DC output to a fixed voltage.
Figure (3. Voltage regulator ICs are available with fixed (typically 5V.3) Smoothing action of capacitor
Figure (3.3. The action of the capacitor is shown with the help of waveform. and the ripple is considerably decreased.4) Waveform of the rectified output smoothing 3. 12V and 15V) or
DEPT.KEEP DISTANCE WARNING SYSTEM
The smoothing block smoothes the DC from varying greatly to a small ripple and the ripple voltage is defined as the deviation of the load voltage from its DC value.3. The action of this system depends on the fact that the capacitor stores energy during the conduction period and delivers this energy to the loads during the no conducting period. In this way. Smoothing is also named as filtering.OF DECS. JNNCE SHIVAMOGGA Page 7
. Filtering is frequently effected by shunting the load with a capacitor. the time during which the current passes through the load is prolonging Ted.
Unregulated power supply will be ranging from 9 volts to 24 volts DC . To use these parts we include a regulated 5 volt source.4) Voltage Regulator
3.to make a 5 volt power supply. output and high impedance).
DEPT.KEEP DISTANCE WARNING SYSTEM variable output voltages.5 POWER SUPPLY CIRCUIT:
Fig (3.OF DECS.5) POWER SUPPLY CIRCUIT
Figure (3. Zener diode is an example of fixed regulator which is shown here. we use a LM7805 voltage regulator IC .Many of the fixed voltage regulator ICs has 3 leads (input. JNNCE SHIVAMOGGA
We here by conclude that most of the digital logic circuits and processors need a 5 volt power supply. So.
35 mA max 3-pin interface (power. Maximum 6V) Supply Current: 30 mA typ.OF DECS. ground.1 INTRODUCTION :
Parallax's PING)))™ ultrasonic sensor provides a very low-cost and easy method of distance measurement. an ultrasonic (well above human hearing) pulse is transmitted from the unit and distance-to-target is determined by measuring the time required for the echo return. Naturally.1) ULTRASONIC SENSOR This measures distance using sonar. Several sample codes are available using the Ping))) sensor. The 3-pin header makes it easy to connect using a servo extension cable. PING)))™ Sensor Features:
The PING))) has only has 3 connections.5V. signal) 20 mA power consumption
DEPT. JNNCE SHIVAMOGGA
. Vss. Output from the PING))) sensor is a variable-width pulse that corresponds to the distance to the target. This sensor is perfect for any number of applications that require you to perform measurements between moving or stationary objects.2cm to 3m (~.75" to 10') Supply Voltage: 5V +/-10% (Absolute: Minimum 4. and 1 I/O pin. robotics applications are very popular but you'll also find this product to be useful in security systems or as an infrared replacement if so desired. which include Vdd.
List of technical specifications:
• • • • •
Range .KEEP DISTANCE WARNING SYSTEM
CHAPTER 4 ULTRASONIC SENSOR
4. no soldering required.
Ultrasonic sensors generate high frequency sound waves and evaluate the echo which is received back by the sensor.85 in x 1. The technology is limited by the shapes of surfaces and the density or consistency of the material. burglar alarms. To measure the amount of liquid in a tank. 115 µs to 18. and speed through air or water. and nondestructive testing.40 kHz for 200 µs Size . Systems typically use a transducer which generates sound waves in the ultrasonic range. Further applications include: humidifiers. by turning electrical energy into sound. above 20. fullness of a tank.
DEPT.KEEP DISTANCE WARNING SYSTEM
• • • • • • • •
Narrow acceptance angle Simple pulse in / pulse out communication Indicator LED shows measurement in progress Input Trigger .5 ms Echo Hold-off . Sensors calculate the time interval between sending the signal and receiving the echo to determine the distance to an object. 5 µs typ.positive TTL pulse. sonar.positive TTL pulse.22 mm H x 46 mm W x 16 mm D (0. This technology can be used for measuring: wind speed and direction (anemometer). 2 µs min. For measuring speed or direction a device uses multiple detectors and calculates the speed from the relative distances to particulates in the air or water. For example foam on the surface of a fluid in a tank could distort a reading. JNNCE SHIVAMOGGA
. the sensor measures the distance to the surface of the fluid.OF DECS.000 hertz.750 µs from fall of Trigger pulse Burst Frequency . medical ultrasonography.8 in x 0.6 in)
Ultrasonic sensors (also known as transducers when they both send and receive) work on a principle similar to radar or sonar which evaluate attributes of a target by interpreting the echoes from radio or sound waves respectively. Echo Pulse . then upon receiving the echo turn the sound waves into electrical energy which can be measured and displayed.
Clinicians who perform ultrasound-guided procedures often use a probe positioning system to hold the ultrasonic transducer.
Use in industry. thus producing very high frequency sound waves.OF DECS. Piezoelectric crystals have the property of changing size when a voltage is applied. Alternative methods for creating and detecting ultrasound include magnetostriction and capacitive actuation.KEEP DISTANCE WARNING SYSTEM
An ultrasonic transducer is a device that converts energy into ultrasound. While technically a dog whistle is an ultrasonic transducer that converts mechanical energy in the form of air pressure into ultrasonic sound waves. JNNCE SHIVAMOGGA Page 11
Since piezoelectric crystal generate a voltage when force is applied to them. thus applying an alternating current (AC) across them causes them to oscillate at very high frequencies. the term is more apt to be used to refer to piezoelectric transducers that convert electrical energy into sound.
Ultrasonic sensors are used to detect the presence of targets and to measure the distance to targets in many automated factories and process plants. or sound waves above the normal range of human hearing. the same crystal can be used as an ultrasonic detector. Some systems use separate transmitter and receiver components while others combine both in a single piezoelectric transceiver. The transducer may be passed over the surface of the body or inserted into an body opening such as the rectum or vagina.2 Applications of Ultrasonic sensors: Use in medicine:
Medical ultrasonic transducers (probes) come in a variety of different shapes and sizes for use in making pictures of different parts of the body.
4. Sensors with an on
. which reflects the sound back to the sensor. The system then measures the time for the echo to return to the sensor and computes the distance to the target using the speed of sound in the medium.OF DECS.
Wavelength of Sound as a Function of Sound Speed and Frequency:
The wavelength of sound changes as a function of both the speed of sound and the frequency. These devices typically transmit a short burst of ultrasonic sound toward a target. as shown by the expression: λ = c/f where: λ = wavelength C= speed of light F = frequency Figure 2 is a plot of the wavelength of sound as a function of frequency at room temperature in air. or distance measuring applications.2) PLOT OF WAVE LENGTH VS FREQUENCY BackgroundNoise
proximity. and sensors with an analog output which varies proportionally to the sensor to target separation distance are commercially available.KEEP DISTANCE WARNING SYSTEM or off digital output are available for detecting the presence of objects.
Ultrasonic sensors are commonly used for a wide variety of noncontact presence.
and the noise that is produced is greatly attenuated as it travels through the air. The reason is that less noise at the higher frequencies is produced in the environment.
DEPT.OF DECS. JNNCE SHIVAMOGGA
.KEEP DISTANCE WARNING SYSTEM The level of background ultrasonic noise diminishes as the frequency increases.
So. The output of the detection circuit is detected using the comparator. the side of the positive and the side of the negative of the alternating current signal can be equally amplified. port 0&3 data pins are connected to LCD as data bus.(It is in the OFF condition) This operation is the same as the operation of the comparator. At the circuit this time. the half of the power supply voltage is appied as the bias voltage and it is made 4. the output becomes the saturation state. Port0 can be basically used as I/O port i. the difference is tens of thousands of times amplified and the output becomes 0 V almost. the comparator can not be used .By using 2 ports. When not using this bias voltage.3 Ultrasonic sensor drive circuit:
connected The inverter is used for the drive of the ultrasonic sensor. the difference is tens of thousands of times amplified and the output becomes the same as the power supply almost.OF DECS. Therefore. about twice of Voltage of the inverter output are applied to the sensor.1 INTRODUCTION:
DEPT. at a little input voltage. (It is the saturation state) Oppositely. when the positive input becomes lower a little than the negative input.4. In case of the operational amplifier which doesn't have the negative feedback. it can be programmed as an input
. The operational amplifier amplifies and outputs the difference between the positive.
Generally. The two inverters are KEEP DISTANCE WARNING SYSTEM in parallel because of the transmission electric power increase. Because it is cutting the direct current with the capacitor.e. the distortion causes the alternating current signal. the voltage of the positive input terminal and the voltage of the negative input terminal become equal approximately. JNNCE Page 14 The alphanumeric 16 SHIVAMOGGA character X 2line LCD requires 8data lines and also 3 control
signals and they are interfaced to 3664. the operational amplifier of the single power supply is used instead of the comparator.
The phase with the voltage to apply to the positive terminal and the negative terminal of the sensor has been 180 degrees shifted. the positive and the negative power supply are used for the operational amplifier. because the inner circuit is different about the comparator and the operational amplifier. The circuit this time works with the single power supply of +9 V. When using the operational amplifier with the negative feedback. for the positive input of the operational amplifiers.
CHAPTER 5 LCD DISPLAY CIRCUIT
5. So. by this bias voltage.5 V in the central voltage of the amplified alternating current signal. when the positive input becomes higher a little than the negative input. However.
This circuit is the circuit which detects the ultrasonic which returned from the measurement object.
Further. which does not require a host of associated support chips for its operation as conventional microprocessors do.KEEP DISTANCE WARNING SYSTEM
APPENDIX THEORY OF MICROCONTROLLER
A micro-controller contains a CPU.
Memory Organization of Microcontroller:
The total memory of 89S52 system is logically divided in Program memory and Data memory. There is a cost and space advantage as extra chip costs and printed circuit board and connectors required to support multi-chip systems are eliminated. The upper 128 bytes occupy a parallel address space to the Special Function Registers. It can address 64Kbytes of external program memory under the control of PSEN (low) Gnd vcc preset rs signal. The microcontroller that we use is AT89S52. The 89S52 can address 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 8Kbytes on-chip memory whose map starts from 0000H and ends at 1FFFH. clock circuitry. Program memory is invariably implemented using EPROM. depending upon whether the memory physically exists on the chip or it is externally interfaced. However. variables and constants required for the execution of the program. because it stores only program code which is to be executed and thus it need not be written into. which is relevant in portable control equipment. the data memory may be read from or written to and thus it is implemented using RAM. The other advantages include cheaper maintenance. the program memory and data memory both may be categorized as on-chip (internal) and external memory. a self-contained device. decreased hardware design effort and decreased board density. rw en d0 d1 d2 d3 d4 d5 d6 d7 vcc gnd The AT89S52 implements 256 bytes of on-chip RAM. ROM. while data memory stores the data like intermediate results. That means the upper 128bytes have the same addresses as the SFR space but are physically separate
DEPT. The Micro-controller is therefore. It offers several advantages over conventional multi-chip systems. JNNCE SHIVAMOGGA Page 15
. Ram and I/O circuitry on a single integrated circuit package.OF DECS. Program memory stores the programs to be executed.
When an instruction accesses an internal location above address 7FH.OF DECS.KEEP DISTANCE WARNING SYSTEM from SFR space. JNNCE SHIVAMOGGA
. Instructions that use direct addressing access SFR space.2 PIN CONFIGURATION:
2. the address mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR space.
KEEP DISTANCE WARNING SYSTEM
FIG (2. The voltage source is +5v
DEPT.OF DECS.2) PIN DIAGRAM OF 89S52 IC
2. JNNCE SHIVAMOGGA
.3 PIN DESCRIPTION:
VCC Pin 40 provides Supply voltage to the chip.
Port 1 also receives the low-order address bytes during Flash programming and program verification. As an output port each pin can sink eight TTL inputs. In addition. When 1s are written to port 0 pins. Port 0 also receives the code bytes during Flash programming. and outputs the code bytes during program verification.
Port 1 is an 8-bit bidirectional I/O port with internal pull-ups from pin 1 to 8.OF DECS. as shown in following table.0/T2) and the timer/counter 2 trigger input (P1. Pin 20 is the grounded
Port 0 is an 8-bit open drain bidirectional I/O port from pin 32 to 39. When 1s are written to Port 2 pins they are pulled high by the internal pull-ups and can be used as inputs.
TABLE (2. respectively. JNNCE SHIVAMOGGA Page 18
. The Port 1 output buffers can sink/source four TTL inputs.1/T2EX).3.1 can be configured to be the timer/counter 2 external count input (P1.
DEPT. the pins can be used as high-impedance inputs In this mode P0 has internal pull-ups. P1. As inputs.1) PORT 1 FUNCTIONS
Port 2 is an 8-bit bidirectional I/O port with internal pull-ups from pin 21 to 28. When 1s are written to Port 1 pins they are pulled high by the internal pull-ups and can be used as inputs.KEEP DISTANCE WARNING SYSTEM
GND. Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups.0 and P1. The Port 2 output buffers can sink / source four TTL inputs. External pull-ups are required during program verification.
Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. In this application it uses strong internal pull-ups when emitting 1s. The Port 3 output buffers can sink / source four TTL inputs. During accesses to external data memory that uses 8-bit addresses (MOVX @ RI). Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Upon applying a high pulse to this pin.KEEP DISTANCE WARNING SYSTEM As inputs. Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups.2) PORT 3 FUNCTIONS
Pin 9 is the Reset input. When 1s are written to Port 3 pins they are pulled high by the internal pull-ups and can be used as inputs. 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). the microcontroller will reset and terminate all activities. A high on this pin for two machine cycles while the oscillator is running resets the device.OF DECS. Port 2 emits the contents of the P2 Special Function Register. It is active high.
TABLE (2.3. As inputs.
Port 3 is an 8-bit bidirectional I/O port with internal pull-ups from pin 10 to 17. JNNCE SHIVAMOGGA Page 19
however. Note. the pin is weakly pulled high. EA should be strapped to VCC for internal program executions. except that two PSEN activations are skipped during each access to external data memory. ALE operation can be disabled by setting bit 0 of SFR location 8EH.
DEPT. Note. Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. however.
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.OF DECS. In normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency. PSEN is activated twice each machine cycle.
Program Store Enable is the read strobe to external program memory. If desired. When the AT89C52 is executing code from external program memory. JNNCE SHIVAMOGGA
. This pin is also the program pulse input (PROG) during Flash programming. ALE is active only during a MOVX or MOVC instruction. Otherwise. that one ALE pulse is skipped during each access to external Data Memory. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode. With the bit set. and may be used for external timing or clocking purposes. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming when 12-volt programming is selected. EA will be internally latched on reset. that if lock bit 1 is programmed.
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.KEEP DISTANCE WARNING SYSTEM
Address Latch is an output pin and is active high.
2) EXTERNAL CLOCK DRIVE CONFIGURATION There are no requirements on the duty cycle of the external clock signal.3.
FIGURE (2. Either a quartz crystal or ceramic resonator may be used.OF DECS.KEEP DISTANCE WARNING SYSTEM
Output from the inverting oscillator amplifier. respectively. JNNCE SHIVAMOGGA
. XTAL2 should be left unconnected while XTAL1 is driven .3.3. To drive the device from an external clock source. as shown in Figure 5.1) CRYSTAL CONNECTIONS
FIGURE( 2. since the input to the internal clocking circuitry is through a divide-by two flip-flop. but minimum and maximum voltage high and low time specifications must be observed.
XTAL1 and XTAL2 are the input and output.
DEPT. of an inverting amplifier which can be configured for use as an on chip oscillator.
and the instruction that invokes power down is the last instruction executed. It should be noted that when idle is terminated by a hardware reset. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. up to two machine cycles before the internal reset algorithm takes control.OF DECS. the device normally resumes program execution.4 TIMERS:
• Timer 0 and 1
DEPT. The on-chip RAM and Special Function Registers retain their values until the power down mode is terminated. the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory. The only exit from power down is a hardware reset. but access to the port pins is not inhibited. from where it left off. JNNCE SHIVAMOGGA
. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset. Reset redefines the SFRs but does not change the on-chip RAM.3.KEEP DISTANCE WARNING SYSTEM
In idle mode.
Table (2. the CPU puts itself to sleep while all the on-chip peripherals remain active. The mode is invoked by software.
POWER DOWN MODE
In the power down mode the oscillator is stopped. On-chip hardware inhibits access to internal RAM in this event. The idle mode can be terminated by any enabled interrupt or by a hardware reset. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize.3) Status of External Pins During Idle and Power Down Mode
TL1). Timer 2 consists of two 8-bit registers. JNNCE SHIVAMOGGA Page 23
DEPT. In this function. auto-reload (up or down counting). as shown in Table 5.OF DECS. Timer 2 has three operating modes: capture. There are no restrictions on the duty cycle of external input signal. When the samples show a high in one cycle and a low in the next cycle. TH2 and TL2. the TL2 register is incremented every machine cycle. The type of operation is selected by bit C/T2 in the SFR T2CON. the count is incremented. the register is incremented in response to a 1-to-0 transition at its corresponding external input pin. Since a machine cycle consists of 12 oscillator periods. the level should be held for at least one full machine cycle. the maximum count rate is 1/24 of the oscillator frequency. T2. • Timer 2 Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event counter. The new count value appears in the register during S3P1 of the cycle following the one in which the transition was detected.2. (TH1. TL1) are the 16-bit counter registers for timer/counters 0 and 1. In the Timer function.4) Timer 2 Operating Modes In the Counter function. Register pairs (TH0. and baud rate generator. The modes are selected by bits in T2CON. Since two machine cycles (24 oscillator periods) are required to recognize a 1-to-0 transition.
Table (2. the external input is sampled during S5P2 of every machine cycle.KEEP DISTANCE WARNING SYSTEM Timer 0 and Timer 1 in the AT89S52 operate the same way as Timer 0 and Timer 1 in the AT89S52. the count rate is 1/12 of the oscillator frequency. To ensure that a given level is sampled at least once before it changes. but it should for at least one full machine to ensure that a given level is sampled at least once before it changes.
OF DECS. The Timer 0 and Timer 1 flags. which disables all interrupts at once. These interrupts are all shown in Figure 2. the service routine may have to determine whether it was TF2 or EXF2 that generated the interrupt. EA. 1. Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register T2CON. and 2).5
FIGURE (2. three timer interrupts (Timers 0. JNNCE SHIVAMOGGA
. Neither of these flags is cleared by hardware when the service routine is vectored to. and that bit will have to be cleared in software. and the serial port interrupt. IE also contains a global disable bit.5 INTERRUPTS:
The AT89S52 has a total of six interrupt vectors: two external interrupts (INT0 and INT1). TF0 and TF1.5) INTERRUPTS SOURCE Each of these interrupt sources can be individually enabled or disabled by setting or clearing a bit in Special Function Register IE.
DEPT.KEEP DISTANCE WARNING SYSTEM
2. In fact. are set at S5P2 of the cycle in which the timers overflow.
depending upon whether the memory physically exists on the chip or it is externally interfaced. Program memory stores the programs to be executed. while data memory stores the data like intermediate results. However.KEEP DISTANCE WARNING SYSTEM
Table (2. the program memory and data memory both may be categorized as on-chip (internal) and external memory. JNNCE SHIVAMOGGA Page 25
.OF DECS. The 89S52 can address 8Kbytes on-chip memory whose map starts from 0000H and ends at 1FFFH.5) Interrupts Enable Register
DEPT. Program memory is invariably implemented using EPROM.6 MEMORY ORGANIZATION :
The total memory of 89S52 system is logically divided in Program memory and Data memory. variables and constants required for the execution of the program. It can address 64Kbytes of external program memory under the control of PSEN (low) signal. Further. the data memory may be read from or written to and thus it is implemented using RAM. because it stores only program code which is to be executed and thus it need not be written into.
KEEP DISTANCE WARNING SYSTEM
DEPT.OF DECS. JNNCE SHIVAMOGGA
.KEEP DISTANCE WARNING SYSTEM