<?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>IAP</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/18242/iap</link><description> I am writing to flash memory of LPC2136. 
 
Do I need to erase the segment before writing 
 
Because i wrote garbage when i write to Flash after doing segment preparation only. 
 
every thing fine If i do in following way 
1.)prepare the segments 
2</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: IAP</title><link>https://community.arm.com/thread/138124?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2005 03:00:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:dc18ba69-789b-43de-a70a-e1d6860851fa</guid><dc:creator>Muraletharan Kulasekaram</dc:creator><description>&lt;p&gt;Thank you very much Franc Urbanc&lt;br /&gt;
Best Regards&lt;br /&gt;
Murale&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: IAP</title><link>https://community.arm.com/thread/138126?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2005 02:59:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3b9fafd5-a0dd-4195-8cc0-7af1242cff98</guid><dc:creator>Muraletharan Kulasekaram</dc:creator><description>&lt;p&gt;Thank you very much for the detail discription Drew Davis&lt;br /&gt;
&lt;br /&gt;
best Regards&lt;br /&gt;
murale&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: IAP</title><link>https://community.arm.com/thread/134670?ContentTypeID=1</link><pubDate>Fri, 21 Oct 2005 00:55:41 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4153037e-a123-4f64-a856-bb7c5ed26de8</guid><dc:creator>Franc  Urbanc</dc:creator><description>&lt;p&gt;Here is what the &lt;b&gt;documentation&lt;/b&gt; says about an IAP command Copy RAM to Flash (from LPC213x user manual):&lt;br /&gt;
&lt;br /&gt;
1. Param 0 (DST) - destination Flash address should   be on a &lt;b&gt;256 byte boundary&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
2. Param 1 (SRC) - source RAM address should be a &lt;b&gt;word boundary&lt;/b&gt; (means 32-bit aligned)&lt;br /&gt;
&lt;br /&gt;
3. Param 2 - number of bytes written should be 256 | 512 | 1024 | 2048 | 4096&lt;br /&gt;
&lt;br /&gt;
4. Param 3 (CLK) - system clock Frequency in KHz.&lt;br /&gt;
&lt;br /&gt;
As you see you still need to obey the above rules or you will have problems using IAP Flash programming.&lt;br /&gt;
&lt;br /&gt;
Franc&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: IAP</title><link>https://community.arm.com/thread/134663?ContentTypeID=1</link><pubDate>Thu, 20 Oct 2005 20:18:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e3593829-d3eb-47b4-9be6-15c7e3a18cd3</guid><dc:creator>Drew Davis</dc:creator><description>&lt;p&gt;&lt;i&gt;Can i write 1 or 0 as the same way with out considering the previous state(1 or 0) of the flash?&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
No, not unless this is a really unusual flash technology.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Erasing&amp;quot; a flash device means setting all the bits to 1.  &amp;quot;Programming&amp;quot; a flash means setting some bits to 0.  &amp;quot;Programming&amp;quot; cannot set a bit to 1, and &amp;quot;erasing&amp;quot; cannot set a bit to 0.&lt;br /&gt;
&lt;br /&gt;
Physically, a bit of flash memory is like a little electron corral, surrounded by a &amp;quot;fence&amp;quot; of impassable potential.  Pack a bunch of electrons into the corral, and the bit represents a 1.  Open a hole in the fence, and connect the corral to ground, and all the electrons run out.  Then the corral has a value of 0.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Erasing&amp;quot; a flash means pumping up the internal voltage to the point where you can force electrons into the corral despite the fence around it.  Older flash parts used to have an extra high voltage Vcc input used just for this operation.&lt;br /&gt;
&lt;br /&gt;
Flash has a limited lifetime in terms of erase cycles because this is a fairly brute-force sort of operation, and eventually it wears down the potential barriers around the flash cells to the point where they no longer reliably pen up electrons.  Once electrons can wander in and out of the corrals at their own whim, the device is no longer a reliable storage medium.&lt;br /&gt;
&lt;br /&gt;
For chip layout, density, and cost-per-bit reasons, the circuitry to do the programming isn&amp;#39;t done on a per-bit basis.  Making each bit independently eraseable would cost too much.  Instead, large numbers of bits are grouped together into &amp;quot;pages&amp;quot; or &amp;quot;sectors&amp;quot;.  All the bits in a sector must be erased at the same time.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Programming&amp;quot; the flash means selectively opening up some of those cells and letting the electrons leak out.  Whereever there is a 0 in the word to be programmed, the flash device drains electrons from the corresponding cell.  Programming does nothing to the cells where there is a 1 in the data to be programmed.  Those cells will keep their previous value.&lt;br /&gt;
&lt;br /&gt;
You can program a flash multiple times without erasing it, but all you can do each time is change 1s to 0s.  You can never changes 0s to 1s without using the &amp;quot;erase&amp;quot; operation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: IAP</title><link>https://community.arm.com/thread/123021?ContentTypeID=1</link><pubDate>Thu, 20 Oct 2005 19:58:21 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1edb423d-a241-4e30-81b1-283dfb637362</guid><dc:creator>Muraletharan Kulasekaram</dc:creator><description>&lt;p&gt;Thanks Franc Urbanc for helping me.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Can i write 1 or 0 as the same way with out considering the previous state(1 or 0) of the flash?&lt;br /&gt;
&lt;br /&gt;
Because every thing works fine only after i erase the flash  before write.&lt;br /&gt;
&lt;br /&gt;
It looks i need to change all t0 1 before write 0.&lt;br /&gt;
&lt;br /&gt;
But i cant see any note about this in user manual.&lt;br /&gt;
&lt;br /&gt;
another point is&lt;br /&gt;
LPC213X  flash write size is 256 bytes according to the manual&lt;br /&gt;
and never mention about the start boundary and i think it is fine if i start at word boundary.&lt;br /&gt;
&lt;br /&gt;
Please parden if any thing wrong and let me clear about this.&lt;br /&gt;
&lt;br /&gt;
Regards&lt;br /&gt;
Murale&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: IAP</title><link>https://community.arm.com/thread/111735?ContentTypeID=1</link><pubDate>Thu, 20 Oct 2005 12:47:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:40c3a326-17ce-46fd-a1ee-93f537d69d9f</guid><dc:creator>Franc  Urbanc</dc:creator><description>&lt;p&gt;What is a &lt;b&gt;flash_adr&lt;/b&gt; value? Is it aligned on page boundary?&lt;br /&gt;
For 512 byte pages it should be corrected:&lt;br /&gt;
&lt;pre&gt;
flash_adr &amp;amp;= ~0x0000001FF;
&lt;/pre&gt;
&lt;br /&gt;
What is a &lt;b&gt;size&lt;/b&gt; value? It should be 512 or a multiple of 512 if you want to program more pages in the same function call or want to use next available page size.&lt;br /&gt;
&lt;br /&gt;
Parameter &lt;b&gt;iap.par[3]&lt;/b&gt; should be a system clock frequency in kHz. You do not need to disable PLL, but specify a correct CPU clock for paramter 3.&lt;br /&gt;
&lt;br /&gt;
You might be misleaded by ISP function description. Have in mind that ISP function do already implement the above IAP rules.&lt;br /&gt;
&lt;br /&gt;
Franc&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: IAP</title><link>https://community.arm.com/thread/97592?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2005 05:51:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:44e238f9-cc38-450b-bfd6-ff95805e87f7</guid><dc:creator>Muraletharan Kulasekaram</dc:creator><description>&lt;p&gt;The correct reading is being writen only if i erase before writing.&lt;br /&gt;
&lt;br /&gt;
I dont know where i made mistake&lt;br /&gt;
&lt;br /&gt;
Below the code for write. and I always write to 14 th segment of LPC2136.&lt;br /&gt;
&lt;br /&gt;
_______________________&lt;br /&gt;
unsigned int program (void *flash_addr, void *indata, unsigned int size)  {&lt;br /&gt;
  struct iap_in  iap;                      // IAP input parameters&lt;br /&gt;
  unsigned int result[16];                 // IAP results&lt;br /&gt;
//  unsigned int save_VicInt;                // for saving of interrupt enable register&lt;br /&gt;
&lt;br /&gt;
  save_VicInt = VICIntEnable;              // save interrupt enable status&lt;br /&gt;
  VICIntEnClr = 0xFFFFFFFF;                // disable all interrupts&lt;br /&gt;
&lt;br /&gt;
//--below three added&lt;br /&gt;
	T0IR	=	0x8;						//clear all timer flags  for ADC&lt;br /&gt;
	T1IR	=	0x8;						//clear all timer flags&lt;br /&gt;
	EXTINT	= 	0x0F;						//clear all EINT flags&lt;br /&gt;
&lt;br /&gt;
//#define BYPASS_IAP&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#ifdef BYPASS_IAP&lt;br /&gt;
  stop_pll();                              // IAP requires to run without PLL&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
  iap.cmd = 50;                            // IAP Command: Prepare Sectors for Write&lt;br /&gt;
//  iap.par[0] = get_secnum (flash_addr);    // start sector&lt;br /&gt;
  iap.par[0] = 14;    						// start sector&lt;br /&gt;
//  iap.par[1] = iap.par[0];                 // end Sektor&lt;br /&gt;
  iap.par[1] = 14;                 // end Sektor&lt;br /&gt;
  iap_entry (&amp;amp;iap, result);                // call IAP function&lt;br /&gt;
  if (result[0])  goto exit;               // an error occured?&lt;br /&gt;
&lt;br /&gt;
  iap.cmd = 51;                            // IAP Command: Copy RAM to Flash&lt;br /&gt;
  iap.par[0] = (unsigned int) flash_addr;  // destination-addr&lt;br /&gt;
  iap.par[1] = (unsigned int) indata;        // source-addr&lt;br /&gt;
  iap.par[2] = size;                       // number of bytes&lt;br /&gt;
  iap.par[3] = CCLK;                       // CPU clock&lt;br /&gt;
  iap_entry (&amp;amp;iap, result);                // call IAP function&lt;br /&gt;
&lt;br /&gt;
exit:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  VICIntEnable = save_VicInt;              // enable interrupts&lt;br /&gt;
  return (result[0]);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
------------------------------&lt;br /&gt;
Is there any thing wrong here pl help.&lt;br /&gt;
&lt;br /&gt;
Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: IAP</title><link>https://community.arm.com/thread/87432?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2005 04:43:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fdb74925-4ea9-457d-9df7-93e6b07d7a9b</guid><dc:creator>Franc  Urbanc</dc:creator><description>&lt;p&gt;No, you do not need to erase the segment before writing unless you want to change a 0 to 1 as already stated.&lt;br /&gt;
&lt;br /&gt;
What you need to take care about is that you may write only a &lt;b&gt;page&lt;/b&gt; of 512/1024/... bytes at a time using Philips IAP functions. If you want to program only one byte you still need to read the whole page to ram, change only one byte and again write this modified page back to flash.&lt;br /&gt;
This might be very time consuming if you are writing on a byte access level. It would be better to keep the whole page in RAM and write it, when the page is full.&lt;br /&gt;
&lt;br /&gt;
Franc&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: IAP</title><link>https://community.arm.com/thread/44885?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2005 03:56:38 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a6ff83d3-e433-4852-93b6-e91d2aaa1b28</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;Do I need to erase the segment before writing&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
You need to refer to the &lt;b&gt;Datasheet&lt;/b&gt; for the answer to that!&lt;br /&gt;
&lt;br /&gt;
At the physical hardware level within the chip, you cannot write a &amp;#39;1&amp;#39; to a flash memory bit: Erasing sets bits to &amp;#39;1&amp;#39;; you then program &amp;#39;0&amp;#39; into all the bits that need to be &amp;#39;0&amp;#39;.&lt;br /&gt;
&lt;br /&gt;
However, &lt;i&gt;some&lt;/i&gt; chips have clever logic that automatically does an erase-before-write, giving the &lt;i&gt;appearance&lt;/i&gt; that you can write &amp;#39;1&amp;#39;s to the flash. Again, you need to refer to the &lt;b&gt;Datasheet&lt;/b&gt; to find out if this is the case for your particular chip.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;quot;every thing fine If i do in following way&lt;br /&gt;
1.)prepare the segments&lt;br /&gt;
2.)erase the segments&lt;br /&gt;
3.)prepare the segments&lt;br /&gt;
4.)write to segments&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
This looks very much like you have just answered your own question!&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;quot;this the only method to write to flash.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Again: see the &lt;b&gt;Datasheet&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;quot;my worries is whether each time do i need to erase 32kb segment to write. so i need a copy of this 32kb in the ram.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Yes, that is the usual problem with trying to &lt;i&gt;update&lt;/i&gt; data in Flash...!!  ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>