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,
How to specify a address while writing to EEPROM in 89c51ED2.
It is writing to EEPROM when I give the following code after setting the flags of EECON register.
XBYTE[0x0050] = '1';
But if I declare a variable with following type and assign a value to it, it is not writing to EEPROM
unsigned char xdata *addr; *addr = '1';
//after setting all the flags i write this code for assigning;
*addr = '2';
But this is not writing to EEPROM.
Kindly provide the solution for this.
Dear Dan Henry,
It would be Great help if u could kindly send the code for writing and reading the EEPROM,
The problem with internal XRAM and EEPROM Addressing is causing problem to us,
With Regards,
Murali
Also, although you have not stated that you are doing so, you shouldn't be using the toolchain's LARGE memory model because the function parameters would not be accessible after setting EEE.
Dear,
Thank you giving this information I will try this now and come back to you.
Can I assign the function parameter to the local variable and use it while clearing EEE.
Please inform me.
"Can I assign the function parameter to the local variable and use it while clearing EEE."
If you are using the LARGE memory model, those autos would not be accessible either.
If you are using the LARGE memory model, it would be best to write this function in assembly language where you can load up registers with the parameters before switching to EEPROM access.
Thanx for u kind reply , It was a great help for us.,
we expect the same in future.,
Thanking u ,
Thanking u
thanking micro
is that the opposite of thanks a lot?
Erik
Can I use Global variable and use after setting EEE register
Please reply
"Can I use Global variable and use after setting EEE register"
Note that EEE is a bit - not a register.
Your problem is accessing XDATA - see the description of the EEE bit in the datasheet. It makes no difference whether the variabe is global or "automatic" - the problem is with accessing XDATA.
So, as long as you don't attempt to access anything in XDATA while EEE is set, you should be OK...
I typically design 8051 code using the SMALL model and use explicit xdata qualifiers where necessary, so I have never needed to try this, but you might try explicitly declaring and defining your EEPROM routines to use the SMALL model in your otherwise LARGE model project. For example:
void WriteE2ROM(unsigned char xdata *Addr,unsigned int e_data) small { } unsigned int ReadE2ROM(unsigned char xdata *Addr) small { }
Don't forget to also qualify the extern declarations.
That might be a way of avoiding the assembly language routine.
I'll post this in the other thread also. Why two threads were necessary, I don't know.