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

Problem with AT89C51ED2 EEPROM CODE

Hi,

I have written code for EEPROM of the AT89C51ED2., the code is not working , i have used the instructions as given in the DataSheet, I have tried many times but still I am facing problem, If there any suggestion, I would like to know from Keil,

EEPROM CODE.,

void WriteE2ROM(unsigned char xdata *Addr,unsigned long e_data);
 long ReadE2ROM(unsigned char xdata *Addr);


/*EEPROM  WRITE CODE */

        void WriteE2ROM(unsigned char xdata *Addr,unsigned long e_data)
                {
                                        unsigned char FBuffer[35];
                                        signed char i=-1;

                                        sprintf(FBuffer,"%ld",e_data);

                                        do
                                        {               i++;                                                            // WRITE
                                                        while(BUSY);
                                                        EA=0;
                                                        E_EEPROM;
                                                        *(Addr+i) = FBuffer[i];
                                                        D_EEPROM;
                                                        EA=1;
                                        }while(FBuffer[i]!='\0');
            }


/*EEPROM  READ CODE */

                 long ReadE2ROM(unsigned char xdata *Addr)
                        {
                                        unsigned char EBuffer[35];
                                //      unsigned long FData;
                                        unsigned char idata i=0;


                                        while(BUSY);
                                        EA=0;
                                        E_EEPROM;
                                        while(*(Addr+i)!='\0' && i<32)
                                        {
                                                EBuffer[i] = *(Addr+i);          // READ
                                                i++;
                                        }
                                        D_EEPROM;
                                        EA=1;
                                        EBuffer[i]='\0';
                                        READEEPROM=atol(EBuffer);

                                //      return FData;

                        }

0