Folks: Is there any trick to getting EEPROM to read/write under MPLAB with C18? Until recently I've been working with the 16 series and have not had any problems reading/writing EEPROM both with C (CCS) and with assembly language. However I'm having trouble getting data to either read or write with C18. Here's my configuration: MPLAB 6.52 C18 (latest version) ICD-2 18F252 I've got all code/data protection turned off. I'm trying the following code (in C18): EEADR =0x01; //write to address 1 EEDATA = 0x33; //write the data value 33h EECON1bits.EEPGD = 0; //write to eeprom, not flash program memory EECON1bits.WREN = 1; //allow writes EECON2 = 0x55; EECON2 = 0xAA; EECON1bits.WR = 1; //do the write while (EECON1bits.WR); //wait until done EECON1bits.WREN = 0; //write enable off This is essentially all the code in the program... so I've not worried about disabling interrupts (though I tried that too). When I step through this code in the debugger, I see the register changes that are expected, except register EECON2 does not change. I'm assuming this is because the datasheet says this register doesn't really exist and will always read 0. Yet after I run this code, I examine the contents of the EEPROM (in MPLAB) and register 1 is still 0xFF. If I change the register manually in the EEPROM window of MPLAB, write the data and then read back the data (using program and read) the register does change, so I assume there must be a problem with my code. Anybody see what I'm doing wrong here? Thanks, John Hansen _______________________________________________ http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist