I2c and easyweb

Hi,

I’ve been using a code I got for accessing the eeprom on the easyweb board, however it is very inconsistent. I can read fine, however, the writing gives me a lot of trouble, sometimes it will write and sometimes it won’t and I have no idea on what it depends on.

I’ll have a code like

EE_wr_byte(5, tercer[0]);

EE_wr_byte(6, tercer[0]);

EE_wr_byte(7, tercer[0]);

EE_wr_byte(8, tercer[0]);

EE_wr_byte(9, tercer[0]);

EE_wr_byte(10, tercer[0]);

and it’ll write in every space except the “seven”, and if I change the value of tercer[0] or even the name, it’ll write into that space. I have no idea of what could be the problem, any help would be appreciated.

I have this code right now, and it is only writing on the even memory spaces,

for ( ffft = 0; ffft<25; ffft++)

{

fffv = ffft+8;

EE_wr_byte(ffft, fffv);

abcd = EE_rd_byte(ffft);

}

The code for writing a byte is this:

void EE_wr_byte(int EE_address, char data)

{

unsigned char transfer;

unsigned int temp;

unsigned char control = 0xA0;

P4OUT |= SDA + SCL; //Stop

P4DIR |= SDA + SCL; //Port as output

P4OUT &= ~SDA; //Start

EE_ser_out(control); //Control-byte

temp = (EE_address >> 8); //High byte to send

transfer = temp;

EE_ser_out(transfer);

transfer = EE_address;

EE_ser_out(transfer);

EE_ser_out(data);

P4OUT |= SCL; //Stop

P4OUT |= SDA;

}

void EE_ser_out(char data)

{

unsigned int a;

P4OUT &= ~SCL; //SCL = 0

for(a=0;a<8;a++)

{

if(data & BIT7)

{

P4OUT |= SDA;

}

else

{

P4OUT &= ~SDA;

}

P4OUT |= SCL;

P4OUT &= ~SCL;

data = data << 1;

}

P4DIR &= ~SDA;

P4OUT |= SCL; //Clock-pulse

P4OUT &= ~SCL;

P4DIR |= SDA;

}

thanks