We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
"mostly changing characters to interger variables" Aha! Is that wise? Is it valid? Are you sure that is safe? Remember: the 8051 is an 8-bit processor, and ints are 16 bits in C51. Therefore, changing anything from char to int makes a BIG difference to the code generated by the compiler! In particular, because the code now has to deal with all these 16-bit values in two 8-bit halves, you are much more susceptible to interrupts happening in the middle of the operation and messing things up! Are you sure you have specified everything as volatile that needs it?