Module 2 : Intel 8051 Microcontroller

Lecture 15 : Atmd AT89C51  MicroController Programming

Programming of Microcontrollers

Programming of microcontrollers means writing to the internal program memory. Most of the modern microcontrollers are equipped with central program memory (Flash EEPROM) that can be programmed and erased electrically. Atmel AT89C51 is one such IC. AT89C51 is available in a 40 pin DIP so that it can be easily hooked up in a breadboard or a PCB by a beginner. AT89C51 has 4k byte of Flash program memory. The AT89C51 program memory is programmed byte-by-byte. To program any non-blank on-chip memory, the entire program memory has to be erased before programming.

Two versions of AT89C51 are available so far as the programming voltage is concerned,viz., 5V or 12 V. The advantage of having a 5V programming voltage is that a user can program the memory while the IC is still in the circuit. However, in some applications 12V programming voltage is preferred where a separate programmer is required for programming for safety purpose.

For programming the flash memory, the following connections are made.

Programming the Flash Memory:
Fig 15.1  AT89C51  Connection for Programming
Verifying the Flash Memory:
Fig 15.2  AT89C51 Connection for verification
Control Signals during Flash Programming:

Programming and Data Verification(Read) Timing Diagram :

Fig 15.3  Timing diagram for Programming and Verification

The following steps are taken to program the Flash memory

  1. Input the desired memory location on the address lines(P1.0-P1.7, P2.0-P2.3)
  2. Input the appropriate data byte on the data lines(P0.0-P0.7)
  3. Activate the correct combination of control signals(P2.6,P2.7,P3.6 and P3.7)
  4. Raise   to 12V for high voltage programming mode.
  5. Pulse once to program a byte in the flash memory or the lock bits. It takes about 1.5ms to program a byte.

Repeat steps from 1 to 5, changing the address and data for the entire program memory or till the end of the object file is reached.

Chip Erase : The entire flash memory is erased electrically by suitable combination of control signal as shown in the table and by holding low for 10ms. The entire flash memory is written with all '1's.

Lock bits: lock bits are used for protection of the code memory.
A programmed lock bit is denoted by P.
An unprogrammed lock bit is denoted by U.

Reading the signature bytes:

The signature bytes are read by the same procedure as a normal verification of the location 030H, 031H and 032H, except that P3.6 and P3.7 are pulled down to a logic low. The values read indicate the following status.

(030H) = 1E H indicates manufactured by Atmel.
(031H) = 51 H indicates 89C51.
(032H) = FF H indicates 12V programming.
(032 H) = 05 H indicates 5V programming.