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

How to Reset EEPROM (24C02) Memory using 8051 microcontroller- (Part 42/45)

By Himanshu Choudhary

AT24C02 is two-wire serially programmable EEPROM. This means that for programming, the data and control signals are provided serially along with clock signals from the other wire. The read-write operations are accomplished by sending a set of control signals including the address and/or data bits from a microcontroller.

This project demonstrates the memory reset operation of a 24C02 IC by using AT89C51. For basic operations of AT24C02, refer interfacing serial EEPROM with 8051. It writes & reads a byte to/from the EEPROM displaying it on a 16x2 LCD, and then resets the memory. The results can be monitored on the LCD display.

 


 

 

AT24C02 is a two-wire serial EEPROM from Atmel. 24C02 is an 8 pin IC and reads 8 bit data serially. Its memory size is 2KB. Pins 1- 3 are address pins which are connected to ground. Pin 4 is GND; Pin 5 is SDA (serial data); and pin 6 is SCL (serial clock input). Pin 7 is WP (write protect) pin and is connected to GND. Pin 8 is Vcc for providing power supply. For details on its interfacing and operation, refer interfacing 24C02 with 8051.

The microcontroller monitors the start, stop, acknowledge, send, save, read instructions of EEPROM. The memory can be reset after a power loss, a system reset or an interruption in protocol. The project resets memory after a write and read operation continuously.
 
To reset memory, EEPROM is clocked nine times followed by the start condition. For this, a high SDA signal is looked for in each cycle while SCL is high, i.e., acknowledge function is called 9 times.
 
Memory Reset Clock Cycle Condition
Fig. 2: Memory Reset Clock Cycle condition
 
SDA and SCL pins are connected to P1.0 and P1.1 of AT89C51 and through these pins, serial data transfer takes place. Port P2 of microcontroller is used for connecting LCD data pin while control pins of LCD (RS, RW & EN) are connected to P3.0, P3.1 and P3.6 of the controller. For more details, refer LCD interfacing with AT89C51.  

 

Start condition:
Any read or write operation in EEPROM is initiated by Start condition. This occurs when there is a high to low transition of SDA while SCL is high. (Refer the following diagram) This tells the EEPROM that words from the controller are ready for it. SCL is set low at the end of start condition. This is because any read or write operation first involves transfer of some words to EEPROM. That requires a low to high transition of clock corresponding to each bit of the word.
 
Start Condition To Initialize EEPROM
Fig. 3: Start Condition to initialize EEPROM

Clocking:
When a sequence of words is transferred to EEPROM, a clock is needed to be sent by the controller after transmission of each word. This is required so that the controller can receive its acknowledgement. Clock is just a high transition followed by a low transition of SCL when the initial clock signal is low.
 
Clocking Condition For Acknowledgemnt In EEPROM
Fig. 4: Clocking Condition for acknowledgemnt in EEPROM
 

 

 

Project Source Code

###

//Program for Memory Reset of Serial EEPROM 24C02 using 8051 microcontroller (AT89C51) #include<reg51.h>
#include<intrins.h>		//For using [_nop_()] 'No operation'
sbit sda=P1^0;
sbit scl=P1^1;
sbit led=P0^3;
bit ack;
sbit led1=P0^1;
sfr lcd_data_pin=0xA0;		//Port P2
sfr output=0x80;			//Port P0
sbit rs=P3^0;
sbit rw=P3^1;
sbit en=P3^6;
unsigned char reead,write,write2,i,j;
unsigned int temp;
void delay(unsigned int count)
{
	int i,j;
	for(i=0;i<count;i++)
		for(j=0;j<1275;j++);
}
void lcd_command(unsigned char comm)
{
	lcd_data_pin=comm;
	en=1;
	rs=0;
	rw=0;
	delay(1);
	en=0;
}
void lcd_data(unsigned char disp)
{
	lcd_data_pin=disp;
	en=1;
	rs=1;
	rw=0;
	delay(1);
	en=0;
}
lcd_dataa(unsigned char *disp)
{
	int x;
	for(x=0;disp[x]!=0;x++)
	{
		lcd_data(disp[x]);
	}
}
void lcd_ini()
{
	lcd_command(0x38);		  // for using 8-bit 2 row LCD 
	delay(5);
	lcd_command(0x0F);        // for display on cursor blinking
	delay(5);
	lcd_command(0x80);
	delay(5);
}
void aknowledge()
{
	scl=1;
	_nop_();
	_nop_();
	scl=0;
} 
void start()		//Start condition
{
	sda=1;
	scl=1;
	_nop_();
	_nop_();
	sda=0;
	scl=0;
}
void stop()			//Stop condition
{
	sda=0;
	scl=1;
	_nop_();
	_nop_(); 
    sda=1;
	scl=0;
}
void send_byte(unsigned char value)
{
	unsigned int i;
	unsigned char send;
	send=value;
	for(i=0;i<8;i++)
	{
		sda=send/128;
		send=send<<1;
		scl=1;
		_nop_();
		_nop_();
		scl=0;
	}
	ack=sda;
	sda=0;
}
unsigned char read_byte()
{
	unsigned int i;
	sda=1;
	reead=0;
	for(i=0;i<8;i++)
	{
		reead=reead<<1;
		scl=1;
		_nop_();
		_nop_();
		if(sda==1)
			reead++;
		scl=0;
	}
	sda=0;
	return reead;
}		
void Read()			//Read operation
{
	start();
	send_byte(0xA0);
	aknowledge();
	send_byte(0x00);
	aknowledge();
	start();
	send_byte(0xA1);
	aknowledge();
	i=read_byte();
	aknowledge();
	j=read_byte();
	aknowledge();
	stop();
	if(i==5)
	{
		led=0;
		delay(100);
		led=1;
		delay(100);
		write=i+48;
		lcd_command(0xC6);
		lcd_data(write);	
	}
	else
	{
		led=1;
		lcd_command(0xC6);
		lcd_dataa(' ');
	}
	if(j==65)
	{
		lcd_command(0xC7);
		lcd_data(j);
	}
	else
	{
	    lcd_command(0xC7);
		lcd_data(' ');
	}
	aknowledge();
	i=0;
	j=0;
}

void main()
{
	int k,l,m=0;
	k=0;
	l=0;
	lcd_ini();
	lcd_dataa("Sent :");
	lcd_command(0xC0);
	lcd_dataa("Read :");
	temp=0;
	start();
	while(1)
	{
		while(k<9)        //9 times cycle
		{ 
			k++;
			aknowledge();
		}
		if(k==9)
		{
			k=0;
			start();        //Start condition after 9 times clocking
		}
		Read();
	}
}

###

 


Circuit Diagrams

Circuit-Diagram-EEPROM-24C02-Memory-Reset-Using-8051-Microcontroller-AT89C51

Project Components

  • AT89C51 Microcontroller
  • LCD
  • Serial EEPROM AT24C02

Project Video

Download:
FLVMP43GP

 


Filed Under: 8051 Microcontroller
Tagged With: 8051, eeprom, microcontroller
 

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.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

  • Renesas to demonstrate first working silicon based on the Arm Cortex-M85 processor
  • STMicroelectronics releases first automotive IMU with embedded machine learning
  • Infineon offers DC-DC controller for full LED headlamps without a microcontroller
  • Vishay launches new high-precision, thin-film wraparound chip resistor
  • STMicroelectronics’ common-mode filters ensure signal integrity in serial interfaces

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 renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Temperature sensor readout
  • Capacitive Switches
  • CSI-2 FIFO or Line buffer?
  • What is the function of the long stub?
  • Circuit Performance Exploration

RSS Electro-Tech-Online.com Discussions

  • software PWM
  • Opamp ciruit
  • Audio equalizer
  • Background of Members Here
  • SPI Questions
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