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

i2c interface 89c669

Does the Cx51 compiler support I2C operations such as addressing external RAM for XDATA fetches? Or, do you still have to have the standard RAM (address lines) if you require excess XDATA space (more than 2K in the case of the 89C669)?

Parents Reply Children
  • Not exactly my question. I understand how I2C works. The serial procedure is fine if I request or store data (such as user paramater data) from serial RAM via the I2C protocol. However, if I have runtime variables declared as XDATA, can that XDATA reside in the serial RAM? My guess is NO, since that would require that the compiler generate code that supports an I2C interface. That's why I asked if Keil CX51 compiler supports the I2C interface.

  • "are you asking 'can I address serial memory the same way as parallel?' If so, the naswer is No."

    Actually, the answer is "Yes!"

    You use the compiler's XDATA Banking faclities and write a "driver" so that variables can be defined and used in serial EEPROM just as if they were in "normal" RAM!

    eg, see http://www.keil.com/forum/docs/thread1754.asp

    I think there's an example included with the tools somewhere...

  • "My guess is NO, since that would require that the compiler generate code that supports an I2C interface."

    As you say, the compiler itself doesn't do this. However, it does provide a generic means for accessing "special" memory - typically used where the conventional XDATA space is Banked (paged) to enlarge it above 64K.

    You can use this facility to write a "driver" for accessing serial memory that will then allow the compiler to use variables placed in the serial memory - see above.

    Alternatively, you could just use the conventional approach and write your own write_i2c() and read_i2c() etc functions, and have your application access the EEPROM via these.

  • Note that the PK51 (Professional) Kit is required.

    The examples are in:

    Keil\C51\examples\FarMemory\3 XData Areas on T89C51RD2

    and

    Keil\C51\examples\FarMemory\E2PROM on T89C51RD2

    (note the spaces in the folder names!)

    See the ABSTRACT.TXT file in each folder for further details.

  • one issue:
    If you willy-nilly use serial RAM as XDATA your process speed will comre to a crawl.

    I guess the reason for your question is the old issue "I need more port pins"

    A much better alternative is to use parallel RAM and memory map some I/O.

    -OR- if you do not need more than 64k of code space, switch to the 668 which has 8k of internal RAM

    even more dramatic
    use a SILabs F12x, you get 8 ports, 128k of internal code memory and 8k of internal RAM.

    Erik