Programming the 8051 serial

8051programming

As you see in the figure, programming the 8051 through serial port DB9 connector should be a fairly easy task
Connect the two pins of 8051 to max 232 and then to DB9

So the programming circuit of 8051 should contain no more than 1 chip,some power sources,crystals,capacitors and one connector port.
But when you search online for 8051 programmer circuit, they contain many chip like 89c2051 and whatnot.

Then why cant we program the 8051 using this simple circuit?

By 8051 i mean AT89S51/52.
8051 picture

Best Answer

Fresh from the box these processors don't come with a bootloader so it doesn't 'know' anything about standard serial ports per se but it does have a serial programming mode. It is expecting an external shift clock (SCK) to move serial data to the input pin (MOSI) or to read data from the output pin (MISO).

To quote from the data sheet.

"Serial Programming Algorithm

To program and verify the AT89S51 in the serial programming mode, the following sequence is recommended:

  1. Power-up sequence:

    a. Apply power between VCC and GND pins.

    b. Set RST pin to “H”.

    If a crystal is not connected across pins XTAL1 and XTAL2, apply a 3 MHz to 33 MHz clock to XTAL1 pin and wait for at least 10 milliseconds.

  2. Enable serial programming by sending the Programming Enable serial instruction to pin MOSI/P1.5. The frequency of the shift clock supplied at pin SCK/P1.7 needs to be less than the CPU clock at XTAL1 divided by 16.
  3. The Code array is programmed one byte at a time in either the Byte or Page mode. The write cycle is self-timed and typically takes less than 0.5 ms at 5V.
  4. Any memory location can be verified by using the Read instruction that returns the content at the selected address at serial output MISO/P1.6.15

  5. At the end of a programming session, RST can be set low to commence normal device operation.

Power-off sequence (if needed):

  1. Set XTAL1 to “L” (if a crystal is not used).
  2. Set RST to “L”.
  3. Turn VCC power off.

Data Polling:

The Data Polling feature is also available in the serial mode. In this mode, during a write cycle an attempted read of the last byte written will result in the complement of the MSB of the serial output byte on MISO."