I wrote a simple code to write and read data from EEPROM. The code is working
for all ports except PORTB. What is the problem?
----------------------------------------------------------------------------
void main(){
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
Check the datasheet.
EECON1 contains EEPROM contol bits
EECON2 does not exist physically. That's a virtual register in which you need to write 0x55 and 0xAA (one after the other) before initiating EEPROM write. It serves as a protection from accidental writing into EEPROM. EEPROM_Write() does that for you.