I have just wasted 2 hours trying to figure out why I couldn't write to EEPROM in a 18F26K22. I ended up with just code to write the EEPROM,
I then checked the EEPROM memory window and nothing had changed. I read everything I could find. Tried various things, nothing.
It got to the point where I'm thinking maybe a bug in the chip. To test my sanity, I added a read back from EEPROM and the data was there!!!
Turns out the EEPROM memory window in MPLABX does not show the contents of the EEPROM!!!! What use is that.
I eventually worked out that you can see the EEPROM by doing the following,
Stop the debugger.
Press the Read Memory icon on the ribbon.
Open the EEPROM memory window.
Thanks for nothing Microchip.
Mike.
Code:
EEADR=0x30;
EEADRH=0;
EEDATA=0xAA;
EECON1bits.EEPGD=0;
EECON1bits.CFGS=0;
EECON1bits.WREN=1;
EECON2=0x55;
EECON2=0xAA;
EECON1bits.WR=1;
EECON1bits.WREN=0;
It got to the point where I'm thinking maybe a bug in the chip. To test my sanity, I added a read back from EEPROM and the data was there!!!
Turns out the EEPROM memory window in MPLABX does not show the contents of the EEPROM!!!! What use is that.
I eventually worked out that you can see the EEPROM by doing the following,
Stop the debugger.
Press the Read Memory icon on the ribbon.
Open the EEPROM memory window.
Thanks for nothing Microchip.
Mike.