Hi, I am looking for simple read and write routines for I2C interface between Atmel low-end 89C2051 microcontroller and 24C04 serial EEPROM. Any help would be great . Thanks in Advance. Rocknmoon
Have you looked at the following URL? http://www.keil.com/i2c/ Jon
Philips (the inventor of IIC) has a lot of appnotes, most with code Erik
Thanks for pointing to some of the resourses. Basically i am looking for C code. Bye.
It is difficult/impossible to code timing routines in C, the compiler manufaturer is under no obligation to make code run at specific execution times and often the time is release dependdent. Thus all IIC code will be in assebler. You can, of course make a "hich level" C interface to the assembler code. Erik
Hi, If you're interested, I have written an I2c routine (master mode only) in C. It's still not full mature, but it can give you some idea(s) of how to set up your own. Just send me your email to 'g-vcompernolle at tiscali dot be' and I'll send you the code. Rgds, Geert
Erik, While your comments about writing timing routines in C are true in the general sense, I2C is not a timing specific protocol (at least not for the master). Everything is state based, and as long as your timing is not shorter than the specification, you can change states as slowly as you like. It is entirely possible to make one transition a second, and the protocol will still work.
Richard, can you describe the sequence of states which the master goes through to do simple write and read functions ?? I am trying to implement a write function that can write few bytes into the slave (serial EEPROM). The read function will read in the whole data once at the system power up time. Any help would be great. Bye.
"Basically i am looking for C code." You should not be afraid to use a little assembler where that is the most appropriate solution! Probably the two least appropriate areas for 'C' are timing-critical details, and extensive manipulation of individual bits for low-level hardware IO. This sounds like an ideal application for assembler!
View all questions in Keil forum