Microcontroller 89c51 Used in Robotics

89c51 is an 8-bit microcontroller. It has 4kb of flash programmable and erasable read only memory and 128 bytes of RAM. It can be erased and programmed to a maximum of 1000 times. It is a low-power microcontroller with 32 I/O lines and two 16-bit timers or counters. The 89c51 is designed with static logic for operation down to zero frequency. The microcontroller has a full duplex serial port and on-chip circuitry. Here we will discuss about two of its modes. Idle mode and Power down mode. The idle mode stops the CPU working but allows RAM, serial ports and timers to work and the power-down mode disables the oscillator but idle mode has the advantage of saving RAM contents.

Pin-diagram description

Microcontroller 89c51 consists of 40 pins. There are four ports which are designed as P0, P1, P2 andP3. In these 40 pins P1, P2 and P3 are 8-bit bi-directional ports. Bi-directional means they can be used as both input and output pins. All these ports are 8-bit bi-directional ports, i.e., they can be used as both input and output ports. P0 needs external pull-ups, the others all are internal pull-ups. Port P0 provides low-byte addresses when connected to external memory. Another advatage of this microcontroller is that it has a built-in UART for serial communication.

supply voltage


Port 0

Port 0 is a bi-directional I/o port. In port 0 if '1' is written then the pin is used as high impedance inputs. During Flash
programming, port 0 receives the code bytes. This code is used in verification of the program.

Port 1

Port 1 is also an 8-bit I/O port with internal pull-ups. Port 1 is an 8-bit bidirectional I/O port with internal pull-ups.
Its output buffers can sink/source four TTL inputs. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written, they. As inputs, port 1 receives the low-address during flash programming and program verification.

Port 2

Port 2 is an 8 bit bidirectional I/O port. Port 2 output buffers can sink/source four TTL inputs. When '1' is written on
this port it can be used as input. The Port 2 output buffers can sink/source four TTL inputs. When one is written on this port it can be used as input. In case when we access external data memory port 2 emits high-order address. Port 2 emits the content of special purpose register. During Flash programming, it receives high-order address bits and some control signals during Flash programming and its verification as well.

Port 3

Similarly port 3 is also an 8-bit bidirectional port, its output buffers can source/sink four TTL inputs. To use this port as
an input we need to write '1' as we do in port 1 and 2. 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. It receives some control signals for flash programming and its verification. Port 3 also serves the functions of various special features like:

  • P3.0 RXD (serial input port)
  • P3.1 TXD(serial output port)
  • P3.2 INT0( external input 0)
  • P3.3 INT1(external input 1)
  • P3.4 T0 (Timer 0 external input)
  • P3.5 T1(Timer 1 external input)
  • P3.6 WR (external data memory time strobe)
  • P3.7 RD (external data memory time strobe)

Address Latch enable is used for latching the low-byte of the address while we do access to external memory. This pin is also the program pulse input while we do Flash programming.

Normal Mode

In normal mode emission of ALE is done at a very normal rate. It is at 1/6th of oscillator frequency. It may be used for
clocking purposes or can also be used as external timing. If we want to disable ALE, we can do that by setting '0' of SFR
location 8EH. ALE is active on MOVX or MOVC instruction. This pin is weakly pulled high.


Program Store Enable is actually read to external program memory. With each machine cycle this is activated twice. This activation is done when microcontroller is execution code from program. When the AT89C51 is executing code from external program memory.


When this pin is high and oscillator is working the device gets reset.


If we want to enable the device, then for that EA must be strapped to GND. We enable the device so that it can fetch code from external memory. EA will be internally latched on reset if lock bit 1 is programmed. A should be latched to VCC for internal program executions. EA should be strapped to VCC for internal program executions.


Input to the inverting oscillator amplifier and internal clock operating circuit.


Output from the inverting oscillator amplifier.

Power Down Mode

In the power down mode the oscillator is stopped, and the instruction that invokes power down is the last instruction
executed. The on-chip RAM and Special Function Registers retain their values until the power down mode is terminated. If we want to exit the power down mode we have to reset our Hardware. Another point to be noted is that 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.

Idle mode

In idle mode all the peripherals remain active while CPU stops working. The content of RAM is saved it does not changed, neither the other special function registers. This idle mode can be terminated by enabling any interrupt or Hardware reset.


Here are some useful resources: