hi all
m designing a roject in which m using pic16f684 . want to save data into eeprom.below is the code .please help me find out the mistake. the value isnt saving...what might be the error....
/////////////////////////////////////////////////////////////
// Reads one byte from the EEprom at the specified address //
// and returns it //
/////////////////////////////////////////////////////////////
unsigned char ReadByteFromEE(unsigned char address)
{
unsigned char byte; // Variable hold the data that is read
EEADR = address; // Read from this address
//EEPGD = 0; // Point to EE memory
RD = 1; // Initiate a read cycle
byte = EEDAT; // Fetch byte from dataregister
return byte; // Return the read byte
}
////////////////////////////////////////////////////////////
// Writes one byte to the EEprom at the specified address //
////////////////////////////////////////////////////////////
void WriteByteToEE(unsigned char data, unsigned char address)
{
EEADR = 0x01;// address; // Address to write to
EEDAT = 0x02;// data; // Data to write
WREN = 1; // Enable writes to the EEProm
GIE = 0; // Disable interrupts during write
EECON2 = 0x55; // Write "password" to EECON2
EECON2 = 0xAA;
WR = 1; // Initiate a write cycle
while(!EEIF); // Wait for write to complete
WREN = 0; // Disable writes to EEProm
EEIF = 0; // Clear "write complete" flag
GIE = 1; // Disable interrupts during write
}
////////////////////////////////////////////////////////////////////////////////////////
thanks
m designing a roject in which m using pic16f684 . want to save data into eeprom.below is the code .please help me find out the mistake. the value isnt saving...what might be the error....
/////////////////////////////////////////////////////////////
// Reads one byte from the EEprom at the specified address //
// and returns it //
/////////////////////////////////////////////////////////////
unsigned char ReadByteFromEE(unsigned char address)
{
unsigned char byte; // Variable hold the data that is read
EEADR = address; // Read from this address
//EEPGD = 0; // Point to EE memory
RD = 1; // Initiate a read cycle
byte = EEDAT; // Fetch byte from dataregister
return byte; // Return the read byte
}
////////////////////////////////////////////////////////////
// Writes one byte to the EEprom at the specified address //
////////////////////////////////////////////////////////////
void WriteByteToEE(unsigned char data, unsigned char address)
{
EEADR = 0x01;// address; // Address to write to
EEDAT = 0x02;// data; // Data to write
WREN = 1; // Enable writes to the EEProm
GIE = 0; // Disable interrupts during write
EECON2 = 0x55; // Write "password" to EECON2
EECON2 = 0xAA;
WR = 1; // Initiate a write cycle
while(!EEIF); // Wait for write to complete
WREN = 0; // Disable writes to EEProm
EEIF = 0; // Clear "write complete" flag
GIE = 1; // Disable interrupts during write
}
////////////////////////////////////////////////////////////////////////////////////////
thanks