Hi, I need to write to specific memory location, but when the program calls the function to do it, it does not. This is the function void EEPROMwrite(unsigned int adr, unsigned int dat) { EA=0; // disable Interrupts during write DEECON=(unsigned int)((adr>>8)&0x01); // mode: write byte, set address DEEDAT=dat; // set write data DEEADR=(unsigned char) adr; // start write EA=1; while((DEECON&0x80)==0); // wait until write is complete } I have noticed that when this function is called, DEECON = 0x0E, which is wrong and skips the instruction where DEECON=(unsigned int)((adr>>8)&0x01); Then it gets the data to be written, the address, sets EA and gets out of the function. it does not wait until written is complete why? Thanks