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
Hello Erik I don't think you got the point regarding my code and pastebin.com..
First- Pastebin doesn't require any kind of registration ..just copy and paste and then distribute the link ...other options include - support for formatting in almost 20 languages C,C++,Javak,perl ...even shell..... etc...
Second: please think about my project modules ..I have created libraries myself and I intend to use it in a more modular way ...this way one can understand the modules better and no one would appreciate cramping the whole logic in one C file... and 7000+ Chars well that could evem mean the blank spaces ...tabs etc...and of course the comment beginning for the post as well....
There are altogether 5 files ... 1) .c file containing main() 2) AT24C04-I2C.H & AT24C04-I2C.c --> these are for the I2C routines handling 3) AT24C04-EEPROM.h & AT24C04-EEPROM.c -->these are for the EEPROM routines 4) AT24C04-LCD.h & AT24C04-LCD.c --> these are for LCD handling.
So I would request you to take a look ...and infact I explained where the problem rises ...may be along with the comments in the code you can find that one deceptive error and help me....
thanks and regards
I doubt many hav e the trime to go through your "complete project", reduce the code to just the EEPROM code and post. BTW such a reductionm may, indeed, lead you to find the cause yourself.
OK Erik ...I have almost posted to a dozen forum and I can't find anyone able for this issue because its strange ...I wouldn't had asked you to look into this since if it hadn't been so deceptive I would have just ignored ...but everyone here just can't believe it and have been pondering ..it isn't any logical spaghetti but plain logic ...almost all debugging has been done and timing diagrams,circuit debugging ...almost everything is done ....
I use the same I2C library funcions defined in AT24C04-I2C.c file and the 2 functions are EERPOM_read() and EEPROM_write();
These 2 functions call the same functions from AT24C04-I2C.c file ....whats strange is that EEPROM_write() writes DEVICE ADDRESS,EEPROM REGISTER ADDRESS & USERDATA...
on the the other hand EEPROM_read() writes DEVICE ADDRESS,EEPROM REGISTER ADDRESS & USERDATA... followed by RESTART and then receives the data from EEPROM ..
So no doubt both the EEPROM_read() and EEPROM_write functions call the same I2C related function its only the EEPROM_read() which is succeeding
THIS IS STRANGE AS ITS TANTAMOUNT TO SAYING THE EEPROM_read() is ACTUALLY WRITING FIRST THE DEVICE ADDRESS,EEPROM ADDRESS.....THIS IS A MUST TO FETCH THE USER DATA... and EEPROM_write() whereas does the same thing but just can't write !!!!!!
on a read you write ONE byte, on a write, you write more than one byte. have a look.
if you use a chip such as SILabs or HAVE an ICE, debugging this should be a breeze.
try the code on a SILabs devboard if you do not have an ICE
good tools are half the job, thus buy two sets :)
Erik
So, you have activated people on a dozen forums, without telling people that they are doing the same thing lots of other peoples are also doing.
Cross-posting in itself isn't bad. Cross-posting without adding links to all forums are really not nice.
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
Hello Per Westerrek ...yes I indeed involved other people and they too have beemn pondering about what might have gone wrong ..because they too can't figure out ...this STRANGE error of mine and moreover I have coded it all by myself and now I am trying to get it worked for the past 8 days or so ..hope you can understand the frustration.. I am trying to get max help from all ..but still nothing :( ..heres one post ..
www.edaboard.com/thread232357.html
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
I indeed involved other people and they too have beemn pondering about what might have gone wrong ..because they too can't figure out or maybe did not have the time to extract the significant parts from a "project".
I am trying to get it worked for the past 8 days or so if you, day one, had extracted the EEPROM code into a simple program and published it, you would have been up and running a week ago. Your unwillingness to help those that may be willing to help you only hurts you
btw you keep saying there is no difference between the write before read and a write there is a difference: if your code can wirie one byte, but not multiple bytes, read will work, write will not