Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

AT89S51/52 ISP Programmer – Erase

By Himanshu Choudhary

 
This is the first operation that needs to be performed on the target microcontroller. It is assumed that the target microcontroller has some code in its flash memory. If it does not has any content, write any program in the memory using a programmer. Whenever the flash memory of the chip is erased successfully, it shows ‘FF‘ in all its memory locations. In this project we will erase an 89S51 microcontroller which has some preloaded program in its memory from another microcontroller.
 
The reader should know the basics of sending and receiving the single byte in programming mode. Refer to 8051 Programmer basics before reading this tutorial.
 
The flash memory of the microcontroller is electrically erasable, i.e., it needs electrical pulses to erase the memory. When the four byte instruction corresponding to erase is given to the target microcontroller in the programming mode it erases its internal flash memory. It is important to erase the memory every time the microcontroller is programmed. Once the instruction corresponding to erase has been received the entire memory gets erased, i.e., it does not happens that if the program stored in the memory is occupying only 10% of the entire memory space only this much memory will be erased and rest will be not be erased. In order to perform any operation during the programming mode, the first instruction should always be Programming Enable. It needs to be sent only once and then any operation can be carried out.
 

Circuit Diagram of 8051 Programmer

Fig. 1: Table listing 8051 instructions for programming enable and chip erase

The above table shows the instructions corresponding to programming enable and chip erase. After sending the program enable instruction the target microcontroller sends a byte with value 0x69, which means the programming enable mode has been successfully enabled.
 

Circuit Diagram and Algorithm

Circuit Diagram

Circuit Diagram of 8051 Programmer

 Fig. 2: Circuit Diagram of 8051 Programmer

Algorithm
The algorithm for erasing the chip is as follows:
1.      Power on the circuit.
2.      Send the instruction corresponding to programming enable.
3.      Check the 4th byte on MISO pin. If we receive 0x69 this means chip is enabled.
4.      If programming mode in enabled then send four bytes instruction corresponding to chip erase.

Code

Code

#include<REG51.h>
#include<intrins.h>
#define port P1

sbit sck=port^0;
sbit res=port^3;
sbit miso=port^1;
sbit mosi=port^2;

bit bit1;
unsigned int i,bitno=0;
unsigned char a,b,c,d;

void delay(unsigned int msec)   // Function for delay
{
	int i,j;
	for(i=0;i<msec;i++)
		for(j=0;j<1275;j++);
}

void sendbit()
{
	mosi=bit1;
	delay(1);
	_nop_();
	sck=1;
	delay(1);
	_nop_();
	sck=0;
}

void sendbyte(unsigned char m)
{
	for(bitno=0;bitno<8;bitno++)
	{
		bit1=m/128;
		m=m<<1;
		sendbit();
	}
}

void main()
{
	i=0;
	sck=0;
	res=1;
	delay(500);

//=======Program enable===========
	a=0xac;
	b=0x53;
	c=0x00;
	d=0x11;
	sendbyte(a);
	sendbyte(b);
	sendbyte(c);
	sendbyte(d);

//==========Erase==================
	a=0xac;
	b=0x82;
	c=0x12;
	d=0x13;
	sendbyte(a);
	sendbyte(b);
	sendbyte(c);
	sendbyte(d);
	res=1;
	while(1);
} 


Filed Under: Tutorials
Tagged With: 8051, isp, microcontroller
 

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Designing Gate Driver Circuit and Switching Mechanism for Modified Sine Wave Inverter – (Part 9/17)
  • Completing Modified Sine Wave Inverter Design with Full Bridge Circuit and Step Up Transformer – (Part 10/17)
  • Designing an Offline UPS – Part (12 /17)
  • How to reduce Switching Time of a Relay – (Part 15/17)
  • Testing MOSFET – (Part 16/17)
  • Driving High Side MOSFET using Bootstrap Circuitry – (Part 17/17)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • Designing Gate Driver Circuit and Switching Mechanism for Modified Sine Wave Inverter – (Part 9/17)
  • Completing Modified Sine Wave Inverter Design with Full Bridge Circuit and Step Up Transformer – (Part 10/17)
  • Designing an Offline UPS – Part (12 /17)
  • How to reduce Switching Time of a Relay – (Part 15/17)
  • Testing MOSFET – (Part 16/17)

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd ldr led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics Research robot samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Hotplugging UART
  • Simultaneous start of two small switching power supplies
  • Correct measurement of process variations
  • sensitivity in filters and number of bits of system
  • What is the advantage of using Harmonic Balance solver when compared to Transient solver in ADS?

RSS Electro-Tech-Online.com Discussions

  • How can a 13 bit number represent 16 bit number?Or why is fragmentation offset multiple of 8?
  • None existant errors (MPLAB X)
  • ASM - Enhanced 16F and long calls - how?
  • PCB Photo sensitizing options
  • Passthrough charging-simple but impossible to achieve?
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering