211
void EEPROM_Write(unsigned char address, unsigned char data) { while(EECON1bits.WR); // Wait for write completion EEADR = address; // Set address register EEDATA = data; // Set data register EECON1bits.EEPGD = 0; // Point to data memory EECON1bits.WREN = 1; // Enable write INTCONbits.GIE = 0; // Disable interrupts EECON2 = 0x55; // Write 55h EECON2 = 0xAA; // Write AAh EECON1bits.WR = 1; // Begin write operation INTCONbits.GIE = 1; // Enable interrupts EECON1bits.WREN = 0; // Disable write } unsigned char EEPROM_Read(unsigned char address) { EEADR = address; // Set address register EECON1bits.EEPGD = 0; // Point to data memory EECON1bits.RD = 1; // Read EEPROM return EEDATA; // Return data }