void Save_name()
{
start();
send_byte(0xA0);
aknowledge();
switch(nam)
{
case 0: send_byte(0x00);break;
case 1: send_byte(0x10);break;
.
.
.
case 15: send_byte(0xf0);break;
case 16: send_byte(0x100);break;
case 17: send_byte(0x110);break;
case 18: send_byte(0x120);break;
case 19: send_byte(0x130);break;
case 20: send_byte(0x140);break;
}
aknowledge();
for(i=1;i<16;i++)
{
send_byte(name[i]);aknowledge();
}
stop();
delay_ms(20);
}
void Read_name()
{
start();
send_byte(0xA0);
aknowledge();
switch(nam)
{
case 0: send_byte(0x00);break;
case 1: send_byte(0x10);break;
case 2: send_byte(0x20);break;
.
.
.
case 15: send_byte(0xf0);break;
case 16: send_byte(0x100);break;
case 17: send_byte(0x110);break;
case 18: send_byte(0x120);break;
case 19: send_byte(0x130);break;
case 20: send_byte(0x140);break;
}
aknowledge();
start();
send_byte(0xA1);
aknowledge();
for(i=1;i<16;i++)
{
name[i]=read_byte();aknowledge();
}
stop();
delay_ms(10);
}
send_byte(0x140)
it's data [B]word[/B] address for eeprom...
start();
send_byte(0x[B]xx[/B]); *** use the OR-ed device address as seen below
aknowledge();
switch(nam)
{
case 0: send_byte(0x00);break; *** here use "0xA0" as device address
case 1: send_byte(0x10);break;
.
.
.
case 15: send_byte(0xf0);break;
case 16: send_byte(0x00);break; *** here use "0xA2" as device address
case 17: send_byte(0x10);break; *** mind the missing leading "1"
case 18: send_byte(0x20);break;
case 19: send_byte(0x30);break;
case 20: send_byte(0x40);break;
}
aknowledge();
for(i=1;i<16;i++)
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 void Save_name() { start(); send_byte(0xA0 | ( (nam & 0xF0) >> 3 ) ); // for read : send_byte(0xA1 | ( (nam & 0xF0) >> 3 ) ) aknowledge(); switch(nam) { case 0: send_byte(0x00);break; case 1: send_byte(0x10);break; . . . case 15: send_byte(0xf0);break; case 16: send_byte(0x00);break; case 17: send_byte(0x10);break; case 18: send_byte(0x20);break; case 19: send_byte(0x30);break; case 20: send_byte(0x40);break; } aknowledge(); for(i=1;i<16;i++) { send_byte(name[i]);aknowledge(); } stop(); delay_ms(20); }
i don´t think so.send_byte(0xA0 | ( (nam & 0xF0) >> 3 ) )
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 void Save_name() { start(); send_byte(0xA0 | ( (nam & 0x70) >> 3 ) ); // for read : send_byte(0xA1 | ( (nam & 0x70) >> 3 ) ) aknowledge(); send_byte((nam 0x0F) << 4); aknowledge(); for(i=1;i<16;i++) { send_byte(name[i]); aknowledge(); } stop(); delay_ms(20); }
Venkadesh_M,
ya sir.......it is a variable to find the memory location to store data.....name
as...
for(i=1;i<16;i++)
{
name=read_byte();aknowledge();
}
void Save_name_(int lo)
{
nam=lo;
start();
send_byte(0xA0 | ( (nam & 0x70) >> 3 ) );
aknowledge();
switch(nam)
{
case 0: send_byte(0x00);break;
case 1: send_byte(0x10);break;
.
.
case 15: send_byte(0xf0);break;
case 16: send_byte(0x00);break;
case 17: send_byte(0x10);break;
case 18: send_byte(0x20);break;
case 19: send_byte(0x30);break;
case 20: send_byte(0x40);break;
}
aknowledge();
for(i=1;i<16;i++)
{
send_byte(name[i]);aknowledge();
}
stop();
delay_ms(20);
}
void Read_name()
{
start();
send_byte(0xA0);
aknowledge();
switch(nam)
{
case 0: send_byte(0x00);break;
case 1: send_byte(0x10);break;
.
.
case 15: send_byte(0xf0);break;
case 16: send_byte(0x00);break;
case 17: send_byte(0x10);break;
case 18: send_byte(0x20);break;
case 19: send_byte(0x30);break;
case 20: send_byte(0x40);break;
}
aknowledge();
start();
send_byte(0xA1 | ( (nam & 0x70) >> 3 ) );
aknowledge();
for(i=1;i<16;i++)
{
name[i]=read_byte();aknowledge();
}
stop();
delay_ms(10);
}
Post your send byte code, you are giving 11 bits for each address or 16 bits?
Me too think its only for 8 bits thats what your problem.
unsigned char read_byte()
{
unsigned char reead;
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 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;
}
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 void Save_name() { start(); send_byte(0xA0 | ( (nam & 0x70) >> 3 ) ); // for read : send_byte(0xA1 | ( (nam & 0x70) >> 3 ) ) aknowledge(); send_byte((nam 0x0F) << 4); aknowledge(); for(i=1;i<16;i++) { send_byte(name[i]); aknowledge(); } stop(); delay_ms(20); } void Read_name() { start(); send_byte(0xA0 | ( (nam & 0x70) >> 3 ) ); aknowledge(); send_byte((nam 0x0F) << 4); aknowledge(); start(); send_byte(0xA1 | ( (nam & 0x70) >> 3 ) ); aknowledge(); for(i=1;i<16;i++) { name[i]=read_byte();aknowledge(); } stop(); delay_ms(10); }
Now your problem is reading data..
- - - Updated - - -
I am posting code for both reading and writing so just replace them ..
- - - Updated - - -
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 void Save_name() { start(); send_byte(0xA0 | ( (nam & 0x70) >> 3 ) ); // for read : send_byte(0xA1 | ( (nam & 0x70) >> 3 ) ) aknowledge(); send_byte((nam 0x0F) << 4); aknowledge(); for(i=1;i<16;i++) { send_byte(name[i]); aknowledge(); } stop(); delay_ms(20); } void Read_name() { start(); send_byte(0xA0 | ( (nam & 0x70) >> 3 ) ); aknowledge(); send_byte((nam 0x0F) << 4); aknowledge(); start(); send_byte(0xA1 | ( (nam & 0x70) >> 3 ) ); aknowledge(); for(i=1;i<16;i++) { name[i]=read_byte();aknowledge(); } stop(); delay_ms(10); }
Replace Two functions completely..
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?