Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/16/06 18:19
Read: times


 
#114344 - Easter Gift
Responding to: ???'s previous message
I give you the same Xmas gift I gave earlier
// EEPROM VARIABLES
xdata unsigned short int EEWU_indexTimer          _at_ 0x00;
xdata unsigned short int EEWU_deflectorTimer      _at_ 0x02;
xdata unsigned short int EEWU_doorTimer           _at_ 0x04;
xdata unsigned char      EEWU_roomRelayDelay      _at_ 0x06;
xdata unsigned char      EEWU_boxRelayOn          _at_ 0x07;
xdata unsigned char      EEWU_fuseSimulatorOn     _at_ 0x08;
xdata unsigned char      EEWU_itemCountPulseHi    _at_ 0x09;
xdata unsigned short int EEWU_itemCountPulseLow   _at_ 0x0A;
xdata unsigned short int EEWU_doorOpensMode       _at_ 0x0C;


/******************************************************************************
* NAME          : EEWU_eepromAccessEnable
* DESCRIPTION   : This Function enables onchip EEPROM access of the processor
* INPUT         : Nothing
* OUTPUT        : Nothing
******************************************************************************/
void EEWU_eepromAccessEnable(void)
{
    WMCON |= EEMEN_; //EEPROM access enable
}

/******************************************************************************
* NAME          : eepromWriteEnable
* DESCRIPTION   : This Function enables on chip EEPROM write of the processor
* INPUT         : Nothing
* OUTPUT        : Nothing
******************************************************************************/
static void eepromWriteEnable(void)
{
    WMCON |= EEMWE_; //Write enable
}

/******************************************************************************
* NAME          : eepromWriteDisable
* DESCRIPTION   : This Function disables on chip EEPROM write of the processor
* INPUT         : Nothing
* OUTPUT        : Nothing
******************************************************************************/
static void eepromWriteDisable(void)
{
    WMCON &= ~EEMWE_; //Write disable
}

/******************************************************************************
* NAME          : eepromReadyToWrite
* DESCRIPTION   : This Function shows if EEPROM is ready to write
* INPUT         : Nothing
* OUTPUT        : bit 1 if EEPROM is ready to write
******************************************************************************/
static unsigned char eepromReadyToWrite(void)
{
    return(WMCON & EERDY_);
}

/******************************************************************************
* NAME          : EEWU_writeByte
* DESCRIPTION   : This Function writes a byte to EEPROM.
* INPUT         : char* Address of byte to be stored and unsigned char to write 
* OUTPUT        : Nothing
******************************************************************************/
void EEWU_writeByte(unsigned char* EE_ptr, // out
                    unsigned char value8)
{
    eepromWriteEnable();
    *EE_ptr = value8;
    while(eepromReadyToWrite() == 0)
    {
    }                           // wait till byte is written (about 2.5 msec)
    eepromWriteDisable();
}

/******************************************************************************
* NAME          : EEWU_writeShortInt
* DESCRIPTION   : This Function writes short int to  EEPROM upper byte first
* INPUT         : int* Address of byte to be stored,unsigned short to write 
* OUTPUT        : Nothing
******************************************************************************/
void EEWU_writeShortInt(unsigned short int* EE_ptr2, // out
                        unsigned short int value16)
{
    unsigned char tempVar;
    unsigned char cntr;
    unsigned char* charPtr = (unsigned char*)EE_ptr2;
    tempVar = value16 & 0x0ff; // lower byte
    for(cntr = 0; cntr < 2; cntr++, charPtr++)
    {
        EEWU_writeByte(charPtr,tempVar);
        tempVar = value16 >> 8; // higher byte
    }
}

It was used to access eeprom of AT89S8252.
Not sure if it works for your chip, but you will get the idea
Mahmood

List of 10 messages in thread
TopicAuthorDate
AT89C51ED2 Internal EEPROM            01/01/70 00:00      
   Datasheet            01/01/70 00:00      
      EEPROM            01/01/70 00:00      
         Mr MUHAMMED            01/01/70 00:00      
            Keil            01/01/70 00:00      
         Did you read this            01/01/70 00:00      
            Easter Gift            01/01/70 00:00      
               Thanks            01/01/70 00:00      
               muhammed            01/01/70 00:00      
                  difference            01/01/70 00:00      

Back to Subject List