<?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>Problems with eeprom R/W</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/18639/problems-with-eeprom-r-w</link><description> Hi 
I want to read and write to the internal eeprom in the at89c51ed2. In simulation it seams OK, but in target, the volatile memory is allways read as 0xffh. I use the same routines for same processor in a different project without problems. 
My test</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Problems with eeprom R/W</title><link>https://community.arm.com/thread/97266?ContentTypeID=1</link><pubDate>Sat, 17 Sep 2005 08:26:37 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3155435a-e027-4a1b-a432-d2deff1c6b54</guid><dc:creator>Zona Z</dc:creator><description>&lt;p&gt;Well, after all I have the way:&lt;br /&gt;
&lt;br /&gt;
unsigned char __api_rd_eeprom_byte(unsigned int adr)&lt;br /&gt;
{&lt;br /&gt;
  unsigned char val;&lt;br /&gt;
  bit ea_save;&lt;br /&gt;
  while (EECON&amp;amp;1)&lt;br /&gt;
  	{WDT_feed;	//Watch dog,this &amp;quot;while&amp;quot; many be few mS when you W/R continously&lt;br /&gt;
	};//Eeprom_busy()&lt;br /&gt;
  ea_save=EA;&lt;br /&gt;
  EA=0;&lt;br /&gt;
  EECON |= 0x02;//Enable eeprom data;&lt;br /&gt;
  val=*(unsigned char xdata*)adr;&lt;br /&gt;
  EECON &amp;amp;= ~0x02;//Disable eeprom data;&lt;br /&gt;
  EA=ea_save;&lt;br /&gt;
  return  val;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void __api_wr_eeprom_byte(unsigned int adr, unsigned char value)&lt;br /&gt;
{&lt;br /&gt;
  bit ea_save;&lt;br /&gt;
  while(EECON &amp;amp; 0x01)&lt;br /&gt;
  	{WDT_feed;	//Watch dog,this &amp;quot;while&amp;quot; many be few mS when you W/R continously&lt;br /&gt;
  	};// wait bit busy&lt;br /&gt;
  ea_save=EA;&lt;br /&gt;
  EA=0;&lt;br /&gt;
  EECON |= 0x02;//Enable eeprom data&lt;br /&gt;
  *(unsigned char xdata*)adr=value;&lt;br /&gt;
  EECON &amp;amp;= ~0x02;//Disable eeprom data&lt;br /&gt;
  EA=ea_save;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
the api only support 1B&amp;#39;s R/W, so you should do the managment of WORD/DWORD type&amp;#39;s Read/Wrote...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Michael Christensen &lt;/b&gt;&amp;#39;s problem is because his routine is for T89C51ED2, not AT89C51ED2, Atmel has a pdf told you the difference between these 2chip... and the routine in this post is for AT89C51ED2... Hope it can help the newer...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with eeprom R/W</title><link>https://community.arm.com/thread/73330?ContentTypeID=1</link><pubDate>Sun, 28 Aug 2005 12:35:48 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:750ed07b-79a7-4f13-8c1c-a9411762deb2</guid><dc:creator>Zona Z</dc:creator><description>&lt;p&gt;Sorry for mistype and the file name is &amp;quot;Migration from T89C51RD2 to AT89C51RD2/ED2&amp;quot;&lt;br /&gt;
the link:&lt;br /&gt;
&lt;a href="http://www.atmel.com/dyn/resources/prod_documents/doc4239.pdf" target="_blank"&gt;http://www.atmel.com/dyn/resources/prod_documents/doc4239.pdf&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I am too tired....:(&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with eeprom R/W</title><link>https://community.arm.com/thread/44251?ContentTypeID=1</link><pubDate>Sun, 28 Aug 2005 12:32:21 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d5f8c352-1029-455a-ab93-457de7402fff</guid><dc:creator>Zona Z</dc:creator><description>&lt;p&gt;As the datasheet said , when read and write eeprom, the program must check the EEBUSY to make sure the EEPROM can make the reply.(also need to disable EA if your int routin use the RAM address covered by EEPROM at that time )&lt;br /&gt;
  Please reffer the keil&amp;#39;s sample:&lt;br /&gt;
...Keil\C51\EXAMPLES\FarMemory, they are some sample code in A51 file and you must notice it is for T89C51RD2&lt;br /&gt;
and more, the file &amp;quot;Mifration from T89C51RD2 to AT89C51RD2/ED2&amp;quot; from ATMEL can make you know how to modify the A51 file for ED2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hope these can help all the guys. This above words cost me nearly 40 hours continous work...  :(&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
BR&lt;br /&gt;
Zona&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with eeprom R/W</title><link>https://community.arm.com/thread/73327?ContentTypeID=1</link><pubDate>Mon, 04 Jul 2005 07:47:29 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:789acced-d6b8-46aa-9502-70c32c47459c</guid><dc:creator>Michael Christensen</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;You cannot write 16 bit values to the EEPROM as you have tried to do in your code.&amp;quot;&lt;/i&gt;&lt;br /&gt;
That seams to be the case. I did not see it coming.&lt;br /&gt;
Thank you very much - the show can go on.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with eeprom R/W</title><link>https://community.arm.com/thread/44243?ContentTypeID=1</link><pubDate>Mon, 04 Jul 2005 05:18:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:48476e47-7714-4156-bc46-567b6ee1372e</guid><dc:creator>John Donaldson</dc:creator><description>&lt;p&gt;&amp;quot; I use the same routines for same processor in a different project without problems.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
I can&amp;#39;t see how that could be the case.&lt;br /&gt;
&lt;br /&gt;
Why don&amp;#39;t you just do it exactly the way it is done in the datasheet flowcharts?&lt;br /&gt;
&lt;br /&gt;
You cannot write 16 bit values to the EEPROM as you have tried to do in your code. Write your functions using XBYTE and unsigned char to hold the value to be read/written.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>