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 Keil,
I sloved the EEPROM problem with AT89C51ED2, the problem was in the memory module selection.
Since I had selected large memory model, the EEPROM was not working, when I changed it to Small memory model,it started working fine.
But now my problem is my project is designed for Large memory model , How can I make this code work for Large memory model??
I checked it for Read operation, It was working fine, but It was not able to write to EEPROM with this large model!!
The code is,
/*======================================================================== FUNCTION TO WRITE DATA TO INTERNAL E2ROM OF AT89C51ED2 ========================================================================*/ void WriteE2ROM(unsigned char xdata *Addr,unsigned int e_data) { unsigned char idata FBuffer[6]; char idata i=-1; sprintf(FBuffer,"%d",(unsigned int)e_data); do { while(BUSY); EA=0; E_EEPROM; i++; // WRITE *(Addr+i) =FBuffer[i]; D_EEPROM; EA=1; }while(FBuffer[i]!='\0'); } /*=============================================================== FUNCTION TO READ DATA TO INTERNAL E2ROM OF AT89C51ED2 ===============================================================*/ unsigned int ReadE2ROM(unsigned char xdata *Addr) { unsigned char idata EBuffer[6]; unsigned int idata FData; unsigned char idata i=0; while(BUSY); EA=0; E_EEPROM; while(*(Addr+i)!='\0') { EBuffer[i] = *(Addr+i); // READ i++; } D_EEPROM; EA=1; EBuffer[i]='\0'; FData=atoi(EBuffer); return FData; }
Is there any better approch to write to eeprom ??? If it is please send me the correct way to approch the problem.
1) "Since I had selected large memory model" WHY??? is it because you are too lazy? 2) The sulution is glaringly simple. If you REALLY are too LAZY to write effective code and want to use the LARGE memory model, then rewrite/recompile the EEPROM code.
Erik
"I had selected large memory model"
"WHY??? is it because you are too lazy?"
It may be the case that it is most appropriate in this particular application to have most variables in XDATA. In that case, it makes sense to use the LARGE model and only give specific memory-space qualifiers to the exceptions