We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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; }