Hi,
I'm having some problems using i2c to write to an eeprom, a 24lc515. Sometimes it'll write to it without any problems, and sometimes it won't write at all. The code I am using 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