This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Write fails but Read successful in EEPROM using I2C protocol

Hello there I have almost completed coding interfacing with EEPROM - AT24C04 using I2C protocol,But using this I am able to perform a "READ" operation but not a WRITE.

To reconfirm the working of my Microcontroller Kit,I am using a similar kind of program( found on this forum ) for interfacing the EEPROM using I2C and this program works!!.

This program that I found can do both READ/WRITE....

But when I burn my program on the MC ..it cannot write but it can read the values stored at addresses 0x000,0x001,0x002 using the program found on this forum.

I have checked for the WP(write protect pin) and its alright - connected to ground.

Its strange ..but I coded it all by myself referring the datasheets and timimg diagrams etc..After debugging for almost a week I am unable to find that kind of deceptive error.

If my programs can READ data from EEPROM then its as good as saying that my program can write data to EEPROM because the READ operation requires a DUMMY WRITE and then we would then read the byte from EERPOM.

Can someone let me know as to what mistake I am making ...I could not paste the whole project code I coded since this site doesn't allow more than 7000 characters in one post.

Please take a look at this link http://pastebin.com/fzV9R6hzfor my complete project code.

I have also included the Source code found on the forum for reference since it works for both READ & WRITE

Thanks and regards

Parents Reply Children
  • Hello Erik well I am working on a custom designed kit and the MC is P89V61RD2BN - 8051 from Philips...so no ICE :( ..and moreover I have finished debugging again - I have put a break point at the if condition i.e if( ! SDA ){} ...just to check the timimg on the simulator of KEIL V4 ...everything seems OKAY but again to REPEAT EEPROM_write() is doing the same as EEPROM_read() and checking of ACK is also done and i get the expected results for each of ACK(s) but EEPROM_read() still succeeds and EEPROM_write() fails !!!!

    If you can take a look the way I am handling logic for ACK and if you can give your feedback ..then it would be great....If you get some time ...please let me know thanks

  • the MC is P89V61RD2BN - 8051 from Philips
    could not find a datasheet

    If you can take a look the way I am handling logic for ACK and if you can give your feedback

    as said before: the people that pay me for my time would be upset if I spent the time needed to scour through a "project".

    EXTRACT FROM YOUR CODE A SIMPLE PROGRAM THAT WRITES AND READ FROM EEPROM NOTHING ELSE

    Erik