<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Writing variables to  nonvolitile memory using xdata</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/37782/writing-variables-to-nonvolitile-memory-using-xdata</link><description> 
Writing variables to nonvolitile memory using xdata 

 
My MCU is ADuC841 it had (working with SDK) 

 
 62 kBytes on-chip Flash/EE program memory 
4 kBytes on-chip Flash/EE data memory 

 
I want to store variable that i get from the serial port and</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Writing variables to  nonvolitile memory using xdata</title><link>https://community.arm.com/thread/150309?ContentTypeID=1</link><pubDate>Tue, 29 Apr 2008 07:26:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:24fb0afa-f735-4772-a707-bba02f257553</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;one to write to EEPROM, and one to read from EEPROM&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Which is exactly what this example does:&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.keil.com/download/docs/184.asp"&gt;http://www.keil.com/download/docs/184.asp&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing variables to  nonvolitile memory using xdata</title><link>https://community.arm.com/thread/149867?ContentTypeID=1</link><pubDate>Mon, 28 Apr 2008 13:23:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:df8d92e0-2954-494e-af84-4593637af684</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;How can i declare my EEPROM to be access like an
array&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&lt;b&gt;If&lt;/b&gt;&lt;/i&gt; you want it to be directly accessed as any sort
of standard &amp;#39;C&amp;#39; variable - whether an array or something else -
&lt;i&gt;&lt;b&gt;then&lt;/b&gt;&lt;/i&gt; you will have to use FAR - there is no other
way.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;I didn&amp;#39;t succeed to do it with the FAR&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Then you need to investigate the cause of your failure!&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;my final purpose is to save some struct of char in the
EEPROM&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Is it really?&lt;/p&gt;

&lt;p&gt;
Think about it: a struct is just one for the to
&lt;i&gt;&lt;b&gt;program&lt;/b&gt;&lt;/i&gt; handle the data - it doesn&amp;#39;t &lt;i&gt;necessarily&lt;/i&gt;
have to be &lt;i&gt;&lt;b&gt;stored&lt;/b&gt;&lt;/i&gt; in that way, does it?&lt;/p&gt;

&lt;p&gt;
A common way to handle this is to write a couple of functions: one
to write to EEPROM, and one to read from EEPROM. As far as the
functions (and the EEPROM) are concerned, they are just writing data
- they neither know nor care whether the rest of the program treats
it as a struct, or an array, or a float, or whatever...&lt;/p&gt;

&lt;p&gt;
For an analogy, think about writing data to files, and reading
data from files...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing variables to  nonvolitile memory using xdata</title><link>https://community.arm.com/thread/149405?ContentTypeID=1</link><pubDate>Mon, 28 Apr 2008 12:49:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3e147762-fffd-46e9-a0b0-cde2c086a0dc</guid><dc:creator>mayer yeru</dc:creator><description>&lt;p&gt;&lt;p&gt;
Andy, Hans thanks for your answers&lt;/p&gt;

&lt;p&gt;
How can i declare my EEPROM to be access like an array&lt;/p&gt;

&lt;p&gt;
I didn&amp;#39;t succeed to do it with the &lt;b&gt;FAR&lt;/b&gt;&lt;br /&gt;
declaration as you said in the example -
&lt;b&gt;Keil\C51\EXAMPLES\FarMemory&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
My EEPROM is : (working with ADUC841)&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;The 4 kBytes of Flash/EE data memory are configured as&lt;br /&gt;
1024 pages, each of 4 bytes.&lt;/i&gt;&lt;br /&gt;
(4 kBytes on-chip Flash/EE data memory)&lt;/p&gt;

&lt;p&gt;
my final purpose is to save some struct of char in the EEPROM and
it can&amp;#39;t be done (or you have some other good idea)&lt;br /&gt;
with the solution that above (in the Thread)&lt;/p&gt;

&lt;p&gt;
Thanks,&lt;/p&gt;

&lt;p&gt;
Mayer&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing variables to  nonvolitile memory using xdata</title><link>https://community.arm.com/thread/148914?ContentTypeID=1</link><pubDate>Thu, 24 Apr 2008 00:38:30 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7158bada-09f5-4722-8829-8d226b948804</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;a href="http://www.keil.com/support/man/docs/c51/c51_ap_xbanking.htm"&gt;http://www.keil.com/support/man/docs/c51/c51_ap_xbanking.htm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;The &lt;b&gt;far&lt;/b&gt; memory type allows you to address special
memory areas like EEPROM space or strings in code banking ROM. Your
application accesses these memory areas as if they are a part of the
standard 8051 memory space. Example programs in the folder
&lt;b&gt;C51\EXAMPLES\FARMEMORY&lt;/b&gt; show how to use the C51 far memory type
on classic 8051 devices. If an example that fulfills your
requirements is not provided, you may adapt the access
routines...&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Note that the &lt;b&gt;LX51&lt;/b&gt; linker/locator is &lt;i&gt;&lt;b&gt;required&lt;/b&gt;&lt;/i&gt;
- this is not supported by BL51.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing variables to  nonvolitile memory using xdata</title><link>https://community.arm.com/thread/124612?ContentTypeID=1</link><pubDate>Wed, 23 Apr 2008 23:52:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6eac970b-95bb-4dcd-b26c-500f67c48f9a</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Check if it&amp;#39;s also suitable for your chip:&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.keil.com/download/docs/184.asp"&gt;http://www.keil.com/download/docs/184.asp&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing variables to  nonvolitile memory using xdata</title><link>https://community.arm.com/thread/113861?ContentTypeID=1</link><pubDate>Wed, 23 Apr 2008 23:48:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:afd5da29-c491-4194-8912-4a3b4ff81765</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;Anyhow, there is, somewhere, a &amp;#39;manhandled&amp;#39; banking routine
that makes an EE appear as a (painfully slow) bank of XRAM.&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Yes: look in your &lt;b&gt;Keil\C51\EXAMPLES\FarMemory&lt;/b&gt; folder -
there are specific examples for accessing EEPROM on 80C51RD2 and
T89C51RD2.&lt;/p&gt;

&lt;p&gt;
From the README:&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;The 89C51RD2 EEPROM DEMO program shows you how to use the new
features of C51 Version 6.20 and LX51 Linker/Locater Version 3.20 to
access the data in the EEPROM area.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;This files can be used as template for own projects.&amp;quot;&lt;/i&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing variables to  nonvolitile memory using xdata</title><link>https://community.arm.com/thread/124615?ContentTypeID=1</link><pubDate>Wed, 23 Apr 2008 11:51:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:075c7874-1ad3-4a40-9aab-8627a3c03425</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;Using 6 sfr to program one char (i.e &amp;#39;A&amp;#39;) is too much in my
opinion ?!?!?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Sorry to burst your bubble, but your opinion is entirely
irrelevant in this regard. As is anybody else&amp;#39;s, lest they happen to
be MCU designers.&lt;/p&gt;

&lt;p&gt;
And BTW, writing a single char doesn&amp;#39;t take 6 SFRs --- 4 are quite
sufficient.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;All MCU that i want to program there EE/FLASH data memory is in
that &amp;quot;fashion&amp;quot; ??&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
How could anyone possibly answer that? Nobody but you knows what
&amp;quot;All MCU that i want to program&amp;quot; means.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;What is the advantges of &amp;quot;C&amp;quot; on assembler in this issue
??&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
None. So what?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing variables to  nonvolitile memory using xdata</title><link>https://community.arm.com/thread/113860?ContentTypeID=1</link><pubDate>Wed, 23 Apr 2008 05:21:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f54fa0cc-d60b-4845-9cec-c19932bc6201</guid><dc:creator>mayer yeru</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;b&gt;Andy, Hans&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
I read the datasheet as you said (i did it before i started the
thread)&lt;/p&gt;

&lt;p&gt;
In the datasheet i saw that there is only one way to program the
EE/FLASH data memory.&lt;/p&gt;

&lt;p&gt;
But this method of programing is very (relatively) complex.&lt;br /&gt;
Using &lt;b&gt;6 sfr&lt;/b&gt; to program one char (i.e &amp;#39;A&amp;#39;) is too much in my
opinion ?!?!?&lt;/p&gt;

&lt;p&gt;
My question is that :&lt;/p&gt;

&lt;p&gt;
All MCU that i want to program there EE/FLASH data memory is in
that &amp;quot;fashion&amp;quot; ??&lt;br /&gt;
(using few sfr do to a little change in the EE/FLASH data memory)&lt;/p&gt;

&lt;p&gt;
Using an array of varibles in C (int for example) is very easy
(opposed to ammebler to an array relatively is harder)&lt;/p&gt;

&lt;p&gt;
What is the advantges of &amp;quot;C&amp;quot; on assembler in this issue ??
(writing to the EE/FLASH data memory)&lt;/p&gt;

&lt;p&gt;
Mayer&lt;/p&gt;

&lt;p&gt;
The solution for my first question (writing to the EE/FLASH data
memory - with few changes)&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;&lt;a href="http://www.keil.com/download/docs/184.asp"&gt;http://www.keil.com/download/docs/184.asp&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing variables to  nonvolitile memory using xdata</title><link>https://community.arm.com/thread/100565?ContentTypeID=1</link><pubDate>Wed, 23 Apr 2008 04:55:10 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:89d329e5-1ea4-4a50-aa2e-f50726520e04</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;My question is that - can i do wiritng to the EEPROM&lt;br /&gt;
without all this registers by using XDATA or i must use those
register&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
those amazing designers of chips just add all those SFRs because
they think it is fun to do so.&lt;/p&gt;

&lt;p&gt;
Do you REALLY ASS U ME that all that is there &amp;quot;just to confuse
you&amp;quot;?&lt;/p&gt;

&lt;p&gt;
Anyhow, there is, somewhere, a &amp;quot;manhandled&amp;quot; banking routine that
makes an EE appear as a (painfully slow) bank of XRAM. Since I do not
use it, my recollection is a bit fuzzy, but I think it is for an
external EE so you will have to modify it to use and thus you must
&amp;quot;use those registers&amp;quot;.&lt;/p&gt;

&lt;p&gt;
Now I brought the subject up, I guess someone using it will locate
it for you and, maybe, have some comments on it.&lt;/p&gt;

&lt;p&gt;
Erik&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing variables to  nonvolitile memory using xdata</title><link>https://community.arm.com/thread/102897?ContentTypeID=1</link><pubDate>Wed, 23 Apr 2008 04:55:10 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8d013b1f-0bb3-4e24-ba30-5204027406fe</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;My question is that - can i do wiritng to the EEPROM&lt;br /&gt;
without all this registers by using XDATA or i must use those
register&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
those amazing designers of chips just add all those SFRs because
they think it is fun to do so.&lt;/p&gt;

&lt;p&gt;
Do you REALLY ASS U ME that all that is there &amp;quot;just to confuse
you&amp;quot;?&lt;/p&gt;

&lt;p&gt;
Anyhow, there is, somewhere, a &amp;quot;manhandled&amp;quot; banking routine that
makes an EE appear as a (painfully slow) bank of XRAM. Since I do not
use it, my recollection is a bit fuzzy, but I think it is for an
external EE so you will have to modify it to use and thus you must
&amp;quot;use those registers&amp;quot;.&lt;/p&gt;

&lt;p&gt;
Now I brought the subject up, I guess someone using it will locate
it for you and, maybe, have some comments on it.&lt;/p&gt;

&lt;p&gt;
Erik&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing variables to  nonvolitile memory using xdata</title><link>https://community.arm.com/thread/100561?ContentTypeID=1</link><pubDate>Tue, 22 Apr 2008 15:28:25 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4da92552-c1de-4e19-a373-d941ebbf9cab</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
How many other ways are listed in the &lt;b&gt;Datasheet&lt;/b&gt;...?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing variables to  nonvolitile memory using xdata</title><link>https://community.arm.com/thread/76208?ContentTypeID=1</link><pubDate>Tue, 22 Apr 2008 15:19:57 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:26c1ae45-89ea-4083-8426-a5a02eb1e2dd</guid><dc:creator>mayer yeru</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hans thanks for your answer&lt;/p&gt;

&lt;p&gt;
I read the data sheet and there is about 6 sfr that handle with
the data\program memory&lt;/p&gt;

&lt;p&gt;
My question is that - can i do wiritng to the EEPROM&lt;br /&gt;
without all this registers by using XDATA or i must use those
register (ECON,EADRH\L,EDATA1-4) ??&lt;/p&gt;

&lt;p&gt;
Exmple code from data sheet&lt;br /&gt;

&lt;a href="http://www.analog.com/UploadedFiles/Data_Sheets/ADUC841_842_843.pdf"&gt;www.analog.com/.../ADUC841_842_843.pdf&lt;/a&gt;
(page 34)&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;program tha data F3H into the second byte on Page 03H&lt;br /&gt;
of the Flash/EE data memory space&lt;/i&gt;&lt;/p&gt;

&lt;pre&gt;
        ECON = 6; // Erase all memory

        EADRH = 0;  // high byte
        EADRL = 3;  // low byte
        ECON  = 1;  // Read Page into EDATA1-4
        EDATA2 = 0x0F3;  //overwrite the second byte

        ECON = 5; // ERASE Page
        ECON = 2; // WRITE Page
        ECON = 4; // VERIFY Page
        if (ECON == 0) // Check if ECON=0 (OK!)
           ERROR();  // fuction that handle the error
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
&lt;b&gt;Is that the only way to program the EEPROM ???&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
Mayer&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing variables to  nonvolitile memory using xdata</title><link>https://community.arm.com/thread/49766?ContentTypeID=1</link><pubDate>Tue, 22 Apr 2008 14:04:19 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1635490e-ee51-4a89-95e8-de8bc11147a4</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;Writing variables to nonvolitile memory using xdata&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
You really have to start reading datasheets &lt;b&gt;before&lt;/b&gt; writing
code. The data flash on this device is not, repeat: NOT, accessed
like xdata.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>