Urahara
Member
Hi
I ran into some problems with the internal EEPROM (256bytes) of the above uC. See attached code segments :
Essentially the above pgm assigned char A to address 0x00 and char 2 to address 0x02. Reading 0x02 after the writes gave me a "2".
When I swap the addresses, ie first do a write to 0x02 with char "A', then a write to 0x00 with char "2", a read of 0x02 gave me a "2" instead of the expected result of "A".
It seems that i get the latest write data regardless of which address I specify.
Any thoughts? Thks!
I ran into some problems with the internal EEPROM (256bytes) of the above uC. See attached code segments :
Code:
//Prepare for EEPROM write to address 0x00
EECON1bits.EEPGD = 0;
EECON1bits.WREN = 1;
EEADR = 0x00; //<- to be swapped with address 0x02
EEDATA = 'A';
EECON2 = 0x55;
EECON2 = 0xaa;
EECON1bits.WR = 1;
while (!PIR2bits.EEIF);
PIR2bits.EEIF = 0;
EECON1bits.WREN = 0;EEDATA writes */
//Prepare for EEPROM write to address 0x02
EECON1bits.EEPGD = 0;
EECON1bits.WREN = 1;
EEADR = 0x02; //<- to be swapped with addres 0x00
EEDATA = '2';
EECON2 = 0x55;
EECON2 = 0xaa;
EECON1bits.WR = 1;
while (!PIR2bits.EEIF);
PIR2bits.EEIF = 0;
EECON1bits.WREN = 0;
// Read address 0x02 to verify previous EEPROM writes
EEADR = 0x02;
EECON1bits.EEPGD = 0;
EECON1bits.RD = 1;
string1[0] = EEDATA;
Essentially the above pgm assigned char A to address 0x00 and char 2 to address 0x02. Reading 0x02 after the writes gave me a "2".
When I swap the addresses, ie first do a write to 0x02 with char "A', then a write to 0x00 with char "2", a read of 0x02 gave me a "2" instead of the expected result of "A".
It seems that i get the latest write data regardless of which address I specify.
Any thoughts? Thks!