<?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 to Flash on C8051f350</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/42602/writing-to-flash-on-c8051f350</link><description> Hello, 
 
I have some problem when I try to write to Flash memory. 
 
I read AN201 &amp;quot;WRITING TO FLASH FROM FIRMWARE&amp;quot; and I use write functions for F350 (page 100). 
 
There is no problem with a light program. 
But now I try to integrate these functions</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Writing to Flash on C8051f350</title><link>https://community.arm.com/thread/97245?ContentTypeID=1</link><pubDate>Thu, 23 Jun 2005 08:51:56 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2dd132e3-314c-4390-b02d-a183b3835104</guid><dc:creator>Heddy nothing</dc:creator><description>&lt;p&gt;Thank you for your help,&lt;br /&gt;
&lt;br /&gt;
Finally, I just forgot a word (very important).&lt;br /&gt;
&lt;br /&gt;
In my write function, i declared the write pointer like this :&lt;br /&gt;
&lt;pre&gt;char xdata * pwrite;&lt;/pre&gt;
&lt;br /&gt;
The space where this pointer is stored isn&amp;#39;t defined.&lt;br /&gt;
In small memory model, the compiler put it in data, no problem. But with compact or large model, the compiler put it in xdata, doesn&amp;#39;t work.&lt;br /&gt;
&lt;br /&gt;
I just wrote :&lt;br /&gt;
&lt;pre&gt;char xdata * &lt;b&gt;data&lt;/b&gt; pwrite;&lt;/pre&gt;
and it works.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to Flash on C8051f350</title><link>https://community.arm.com/thread/97227?ContentTypeID=1</link><pubDate>Wed, 22 Jun 2005 10:57:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:96a63d13-89d3-4239-9f03-891fc07799f8</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;The memory model choses has nothing to do with program size.&amp;quot;&lt;/i&gt;&lt;br /&gt;
What I tried to say was &amp;quot;if you have a large program, you do not HAVE TO choose the large model&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to Flash on C8051f350</title><link>https://community.arm.com/thread/87260?ContentTypeID=1</link><pubDate>Wed, 22 Jun 2005 10:56:22 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5e1b80f6-9119-42ec-8142-222f4617360c</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;yes, interrupts MUSt, of course be disabled, the trouble the OP is seing is the compiler wiring/reading XDATA (with large memory model) after the SFR (whatever the name, whatever the bit) is cahnged to redirect XDATA operations/writes to flash.&lt;br /&gt;
&lt;br /&gt;
an illustration from my codes where I use the high part of a f126 flash as permanent data storage&lt;pre&gt;U8 ReadFlashChar (U8 code *  RFSaddr)
{
U8 RFCintsav;
U8 RFCdata;

  RFCintsav = SG_IE;
  SG_IE = 0;
  SG_SFRPAGE = 0;
  if (RFSaddr &amp;gt; 0x7fff)
  {
    SG_PSBANK = 0x30;
  }
  else
  {
    SG_PSBANK = 0x20;
    RFSaddr   += 0x8000   ;
  }
  RFCdata = *RFSaddr;
  SG_PSBANK = 0x10      ;
  SG_IE = RFCintsav;
  return (RFCdata) ;
}

If RFCdata were mapped to XDATA, it would be written to flash.


Erik
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to Flash on C8051f350</title><link>https://community.arm.com/thread/87259?ContentTypeID=1</link><pubDate>Wed, 22 Jun 2005 09:46:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e27fd797-58b9-4b8f-9224-148cca87005c</guid><dc:creator>John Donaldson</dc:creator><description>&lt;p&gt;&amp;quot;what does program size have to do with it?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
He would seem to be referring to the large memory model.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;The memory model choses has nothing to do with program size.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Although the program size will probably increase if the large model is used.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to Flash on C8051f350</title><link>https://community.arm.com/thread/44200?ContentTypeID=1</link><pubDate>Wed, 22 Jun 2005 09:42:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9d02c920-a0f8-43dd-86bf-cf8667445ebc</guid><dc:creator>John Donaldson</dc:creator><description>&lt;p&gt;&amp;quot;Is there a solution to write to flash memory with a large program ?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
I&amp;#39;m not familiar with your particular derivative, but I&amp;#39;m assuming that the procedure to write to the flash is something like:&lt;br /&gt;
&lt;br /&gt;
1) Map the flash into xdata space&lt;br /&gt;
2) Write to flash&lt;br /&gt;
3) Map the flash back out of xdata space&lt;br /&gt;
&lt;br /&gt;
If an interrupt occurs during this sequence and the associated ISR accesses the xdata memory space you are in trouble. One solution is to disable interrupts before step (1) and reenable them after step (3).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing to Flash on C8051f350</title><link>https://community.arm.com/thread/44199?ContentTypeID=1</link><pubDate>Wed, 22 Jun 2005 08:07:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ad29ff95-5671-40a0-b675-338a4d0fb40f</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;i&gt;Is there a solution to write to flash memory with a large program ? &lt;/i&gt;&lt;br /&gt;
what does program size have to do with it?.  The memory model choses has nothing to do with program size.&lt;br /&gt;
&lt;br /&gt;
Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>