Last active
March 13, 2018 06:28
-
-
Save SaheblalBagwan/298475e85839ea9b379bbc2dd9348baf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void EEPROM_WriteByte(unsigned char eepromAddress, unsigned char eepromData) | |
{ | |
unsigned char gie_Status; | |
while(WR); // check the WR bit to see if a previous Write operation is in progress | |
EEADR=eepromAddress; // Write the address to EEADR. | |
EEDATA=eepromData; // load the 8-bit data value to be written in the EEDATA register. | |
WREN=1; // Set the WREN bit to enable eeprom operation. | |
gie_Status = GIE; // Copy the current Interrupt state | |
GIE = 0; // Disable the interrupts | |
EECON2=0x55; // Execute the special instruction sequence | |
EECON2=0xaa; // Refer the datasheet for more info | |
WR=1; // Set the WR bit to trigger the eeprom write operation. | |
GIE = gie_Status; // Restore the interrupts | |
WREN=0; // Disable the EepromWrite | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment