7 CHAPTER 3 MICROCONTROLLER AT89s52 3.1 INTRODUCTION A microcontroller is an integrated chip that is often part of an embedded system.

The microcontroller includes a CPU, RAM, ROM, I/O ports, and timers like a standard computer, but because they are designed to execute only a single specific task to control a single system, they are much smaller and simplified . 3.1.1 Architecture Architecture of Microcontroller is classified into two types: Data Flow and Instruction. Data Flow There are two types of architecture in data flow. They are : • Von Neumann Architecture • Harvard Architecture One shared memory is only available for instructions (program) and data instructions and data have to be fetched in sequential order in case of Von Neumann architecture. The Harvard architecture on the other hand uses physically separate memories for their instructions

1. Until the mid-1980s. RISC This is a type of architecture that recognizes a relatively limited number of instructions.2 Instruction Type There are two types of architecture in instruction type. a number of computer manufacturers decided to reverse this trend by building CPUs capable of executing only a very limited set of instructions. Instructions and Operands can therefore be fetched simultaneously. One advantage of reduced instruction set computers is that they can execute their instructions very fast because the instructions are so simple. A CISC microprocessor contains a more complex set of instructions that it responds to and some of these instructions cannot be completed in one machine cycle. . requiring dedicated buses for each of them.8 and data. 3. however. They are • CISC • RISC CISC CISC architecture supports as many as 200 instructions. At that time. the tendency among computer manufacturers was to build increasingly complex CPUs that had ever-larger sets of instructions .

2 FEATURES OF AT89s52 • • • 8 bit Microcontroller 8K bytes of Flash Programmable and Erasable ROM Fully Static Operation: 0 Hz to 24 MHz 10 . or the ROM is an electrically reprogrammable read only memory (EPROM). and other cost-sensitive features.1. or they may be very low. but differ in the amount of internal ROM.Bit Controller Application volumes for the 8-bit microcontrollers may be as high as the 4-bit models. the microcontroller has no on-board ROM at all.9 3. Often the memory can be expanded to include off-chip ROM and RAM.3 8. All features a common language. For these reasons. the microcontroller vendors have established extensive “families “of similar models. Application sophistication can also range from simple application control to high-speed machine control and data collection. Manufacture: Pins/I/O Counter RAM ROM : : : : Intel 8051 40/32 2 256bytes 8K 3. RAM. in some cases.

P2. Port 0 may also be configured to be a multiplexed low order address/data bus during accesses to external program and data memory. To use the pins of port 0 as both input and output ports. they can be used as high impedance inputs. When 1s are written to port 0 pins. It receives code bytes during flash programming. each pin must be connected externally to a 10KΩ pull-up resistor . unlike P1.P3.3 PIN DESCRIPTION Vcc: Supply Voltage (Pin 40) GND: Ground (Pin 20) Port 0 It occupies a total of 8 pins (32-39) which can be used as both input and output. 11 .• 256* 8-bit Internal RAM 32 Programmable I/O Lines 6 Interrupt Sources Two 16 bit Timer/Counters Programmable Serial Channel Low Power Idle and Power-down modes Three level Program Memory Lock • • • • • • 3.This is due to the fact that P0 is an open drain.

7 are used to provide the read and write signals( active. It is a bidirectional port with internal pull ups. P3. they can be used as inputs. It also receives control signals during flash programming and verification. It receives higher order address bits and control signals during flash programming and verification.low) of external memories. they can be used as inputs. they are used as inputs.3 and 3. Pins 3. Port 2 It occupies a total of 8 pins (21-28).4 are used for timers 0 and 1. 12 . Port 3 has the additional function of providing some extremely important signals such as interrupts.0 and P3.3 are set for external interrupts. Bits 3.2 and 3.1 are used for RxD and TxD serial communication signals. It is a bidirectional port with internal pull ups. It is bidirectional port with internal pull ups. When 1s are written to port 1. It receives low order address bytes during flash programming and verification. Bits 3.6 and 3.When 1s are written to port 3. It emits higher order address bytes during fetches from external program memory and during accesses to external data memory that uses 16 bit address. When 1’s are written to port 1.Port 1 It occupies a total of 8 pins(1-8). Port 3 It occupies a total of 8 pins (10-17).

XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. 13 .Table 3. Activating a power-on reset will cause all values in the registers to be lost. This is often referred to as Power-On reset. (Pin 19) XTAL2 Output from the inverting oscillator amplifier (Pin 20). It will set Program Counter to all 0s.1 Pin details of Port 3 – Special Function Port RST Reset Input (Pin 9). A high on this pin (normally low) for two machine cycles while the oscillator is running resets the device.

3. This pin is also the program pulse input (PROG) during flash programming. PSEN Program Store Enable is the read strobe to external program memory (Pin 29). EA/VPP External Access Enable (Pin 31).ALE/PROG Address Latch Enable output pulse (Pin 30) for latching the low byte of the address during accesses to external memory. EA should be strapped to Vcc for internal program executions. EA must be strapped to ground in order to enable the device to fetch code from external program memory locations. It also receives the 12V programming enable voltage during flash programming.4 ADVANTAGES OF AT89C51 • • • • Cost effective Low Power Highly flexible High performance .

14 Figure 3.1 Pin Diagram of AT89C51 .