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

EEPROM C-code for T89C51CC01/02

Dear,

I'm not able to communicate with the internal EEPROM from the CC01 device.

Has anybody any C-sample code that helps me get started?

I'm not able to port the asm-code to C-code.

Help needed.


  • Me too, I didn't succeed in using C to communicate with the EEPROM. I wrote a little code in assembler 8051 to use the EEPROM.

    would you like it ?

  • Any help will do the job ...

    Thanks in advance.

    Is there nobody that has succeeded in writing C code for this EEPROM-component?




  • Dear Christophe,

    Can you email me your solution?


    xptsep@hotmail.com.

    Kind regards.

  • We made a full adapation of the 'far' memory type available in the PK51 package. With the help if the XBANKING.A51 it is possible to adapt the 'far' memory access routines to drive the EEPROM. Please take a look to the example
    C:\Keil\C51\EXAMPLES\FarMemory\E2PROM on 80C51RD2.

    It shows EEPROM programming with the T89C51RD2 that is almost identical with the T89C51CC01.

  • #define EEE 0x02
    #define EEE_reset 0xFD
    #define EEBUSY 0x01

    void WaitUntilReady(void)
    {
    while ((EECON & EEBUSY) == EEBUSY);
    }

    char ReadEEPROM (unsigned int EEPROMAddress)
    {
    char xdata *p_eeprom;
    char ReadOut;
    WaitUntilReady();
    EECON |= EEE;
    p_eeprom = (char xdata*) EEPROMAddress;
    ReadOut = *p_eeprom;
    EECON &= EEE_reset;
    return (ReadOut);
    }

    void CommitEEPROM (void)
    {
    WaitUntilReady();
    EECON = 0x50;
    EECON = 0xA0;
    }

    void WriteEEPROM (unsigned int EEPROMAddress,unsigned char EepromData)
    {
    char xdata *p_eeprom;
    WaitUntilReady();
    EECON |= EEE;
    p_eeprom = (char xdata*) EEPROMAddress;
    *p_eeprom = EepromData;
    EECON &= EEE_reset;
    CommitEEPROM();
    }


    void main (void)
    {
    // SIMPLE WRITE & READ COMMAND
    WriteEEPROM (0x0001,0xAA);
    WriteEEPROM (0x0002,0x55);
    ReadEEPROM (0x0001);
    ReadEEPROM (0x0002);
    }