This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem in iterfacing AT24C16A serial eeprom

I have interfaced P3.3to scl & sda to p3.4.........
#include<REGX51.H>
#include<stdio.h>
#define LCD_DELAY=56
void acknowlg();
void start();
void stop();
void read();
void write(unsigned char p);
void delay(unsigned int ms);
int a,b,c,d,i;
void main()//operate eeprom.
{ stop();
start();
write(0xA0);
acknowlg();
write(0xAA);
acknowlg();
P1_2=0;
//write(0xFF);
acknowlg();
stop();
delay(1);
start();
write(0xA1);
acknowlg();
read();
stop();
P3=d;
P1=d;
while(1);
} void delay(unsigned int ms)//1 ms delay(variable).
{ unsigned int n; unsigned int i;

for (n=0; n<=ms; n++) { for (i=0;i<LCD_DELAY;i++); }

}
void start()//start the communication (h to L)
{ P3=0x00;
P3_4=1;
P3_3=1;
delay(1);
P3_4=0;
delay(1);
P3_3=0;
} void stop()//stop the communication(L to h)
{ P3_4=0;
P3_3=1;
delay(1);
P3_4=1;
delay(1);
P3_3=0;
} void write(unsigned char p)//write in serial order
{ P3=0x00;
P2=p;
for(a=0;a<8;a++)
{ P3_3=1;
delay(1);
P3_4=P2_7;
delay(1);
P2=P2<<1;
P3_3=0;
} P3=1;
delay(2);
P3=0;

BUT UNABLE TO DO IT PLS TELL ABT ACKNOWLEDGE FUNCTION AND CODE FOR ME IF POSSIBLE..............
} void acknowlg()//seek acknowledgement from memory
{ //P3=0xFF;
P3_3=1;
delay(1);
while(P3_4==0)
{ }
delay(1);
P3_3=0;
} void read()//to read byte from eeprom.
{

for(b=0;b<3;b++)
{ i=P3_4;
P3_3=1;//set as input.
delay(2);
P3_3=0;
P3=P3<<1;
} P3_3=1;
delay(2);
P3_3=0;

for(b=0;b<4;b++)
{ //P3_3=1;//set as input.
delay(2);
P3_3=0;
P3=P3>>1;
} acknowlg();
P3_3=1;
delay(2);
P3_3=0;
}

Parents
  • Do you thing your code looks readable? Did you check what it looked like in the preview? Repost the code, but this time following the posting instructions for code!

    Second: Don't you think you should expand a bit on your question?

    BUT UNABLE TO DO IT PLS TELL ABT ACKNOWLEDGE FUNCTION AND CODE FOR ME IF POSSIBLE..............

    Unable to do what? What do you expect should happen? What happens? What steps have you taken to figure out the problem?

Reply
  • Do you thing your code looks readable? Did you check what it looked like in the preview? Repost the code, but this time following the posting instructions for code!

    Second: Don't you think you should expand a bit on your question?

    BUT UNABLE TO DO IT PLS TELL ABT ACKNOWLEDGE FUNCTION AND CODE FOR ME IF POSSIBLE..............

    Unable to do what? What do you expect should happen? What happens? What steps have you taken to figure out the problem?

Children