thank you sivaram my code is below
#include<reg51.h>
#include<stdlib.h>
#include<stdio.h>
sbit SDA=P3^5;
sbit SCL = P3^4;
unsigned char tempdata;
unsigned char check=0x00;
void sent (unsigned char dat);
void delay()
{
unsigned char i;
for(i=0x00;i<0xFF;i++);
}
void longdelay(void)
{
int h,s;
for(s=0;s<0x50;s++)
for(h=0;h<0xFF;h++);
}
void scl_high()
{
hg:
SCL=1;
if(SCL!=1)
goto hg;
}
void start()
{
SDA=1;
scl_high();
SDA=0;
delay();
SCL=0;
}
void stop()
{
SDA=0;
scl_high();
SDA=1;
}
void write (unsigned char data1)
{
unsigned char i;
for(i=0;i<8;i++)
{
// SCL=0;
if (data1 & 0x80)
{
SDA = 1;
}
else
{
SDA = 0;
}
scl_high();
data1 = data1 << 1;
delay();
SCL= 0;
}
sent(0x30+check++); //1,3 6 9 b e n
//SDA = 1;
delay();
scl_high();
sa:
if (SDA != 1)
{
goto sb;
sent('k');
}
else
{
goto sa;
sent('h');
}
//sent(0x30+check++); //2 4 7 a c f
sb:
delay();
SCL=0;
delay();
sent('z');
}
void read()
{
unsigned char j;
unsigned char tp;
unsigned char dat;
SDA = 1;
for(j=0;j<8;j++)
{
scl_high();
tp = SDA;
if (tp==1)
dat = (tempdata | 0x01);
else
dat = (tempdata & 0xFE);
tempdata = dat<<1;
SCL = 0;
delay();
delay();
delay();
}
sent(0x30+check++);
scl_high();
SCL=0;
sent(0x30+check++);
sent('y');
}
void eeprom_write(unsigned char address1,unsigned char address2, unsigned char dat)
{
start();
sent(0x30+check++); //0 c
write(0xA2);//1 d
write(address1);//2 e
sent(0x30+check++);//3 f
write(address2);//4 g
sent(0x30+check++);//5 h
write(dat);//6 i
stop();
}
void eeprom_read(unsigned char address1,unsigned char address2)
{
start();
write(0xA2);//7 j
sent(0x30+check++); //8 k
write(address1); //9 l
sent(0x30+check++); //10 m
write(address2);//11 n
sent('x');
sent(0x30+check++);//12
stop();
sent(0x30+check++);//13
start();
write(0xA3);//14
sent(0x30+check++); //15
read();
sent(0x30+check++);//B
stop();
}
void sent (unsigned char dat)
{
SBUF = dat;
while(!TI);
TI=0;
}
void send_data()
{
unsigned char R;
unsigned char J;
R = tempdata & 0xF0;
R = R >> 4;
R = R + 0x30;
sent (R);
J = tempdata & 0x0F;
J = J + 0x30;
sent (J);
}
void main(void)
{
//unsigned char address ;
//unsigned char dat ;
EA=0;
longdelay();
longdelay();
longdelay();
longdelay();
TMOD = 0X20;
SCON = 0X50;
TH1 = 0XFD;
TR1=1;
while(1)
{
eeprom_write(0x00,0x00,0x3E);
sent(0x01);
eeprom_read(0x00,0x00);
sent(0x02);
send_data(); //FE
eeprom_write(0x00,0x01, 0x2E);
eeprom_read(0x00,0x01);
send_data();
eeprom_write(0x00,0x08, 0xEA);
eeprom_read(0x00,0x08);
send_data();
eeprom_write(0x0F,0xFF, 0XFE);
eeprom_read(0x0F,0xFF);
send_data();
sent('E');
sent('N');
sent('D');
sent(' ');
}
} and i am getting ouput on hyperterminal as
01z2z34z56z7z89z:;zx<=>z?@AyB?>CDzEzFGzHIzJzKLzMN
---------- Post added at 08:25 ---------- Previous post was at 08:24 ----------
thank you seadolphine