Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/05/06 11:28
Read: times


 
#111281 - Wait for the write to complete
Responding to: ???'s previous message

You don't seem to wait for the write operation to complete. Add a delay of 5-10mS before trying to read the device.

As for the value of 0x50 - the address is 7 bits and the r/w is a bit - together they make 8 bits. Get 0x50,shift 1 bit left and you get 0xa0.



Also, why do you do this?

value = 0xA0; // device address
i2cdatawrite(value);
value = 0x00; // data word address
i2cdatawrite(value);
value = 0xA1; // device address with R/W = 1;
i2cstart();
i2cdatawrite(value);

Why not:-

#define EEPROM_ADDR_W 0xa0
#define EEPROM_ADDR_R 0xa1

i2cdatawrite(EEPROM_ADDR_W);
i2cdatawrite(0x00); //set eeprom read address
i2cstart();
i2cdatawrite(EEPROM_ADDR_R);

There's probably no code sizedifference, but you have less lines of code, which hopefully translates into less defects and is more readable.

also, separate out the routines that access the hardware:-

i2c_start();
i2c_stop();
i2c_write();
i2c_read();
i2c_nack();
i2c_ack();

that way, if your hardware changes you only need to modify these 6 routines.






List of 7 messages in thread
TopicAuthorDate
i2c protocol ,problem writing to eeprom            01/01/70 00:00      
   Wait for the write to complete            01/01/70 00:00      
      but iam getting 00 when reading            01/01/70 00:00      
         send micro an e-mail when you address hi            01/01/70 00:00      
         Don't trust the simulator!            01/01/70 00:00      
   ur read function is not correct            01/01/70 00:00      
      snyone know micro's e-mail address            01/01/70 00:00      

Back to Subject List