<?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>Does it is Possible to Erase &amp;amp; Write Sector 0 in LPC2214</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/25184/does-it-is-possible-to-erase-write-sector-0-in-lpc2214</link><description> 
Hi, 

 
I am implementing a functionality of IAP in LPC2214, for start up
I have written a simple code in which 
I am able to ease Sector 0 &amp;amp; other Sectors as Well, but when I
try to write any data on sector 0 then it is not written it shows all
0xFF</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Does it is Possible to Erase &amp; Write Sector 0 in LPC2214</title><link>https://community.arm.com/thread/146347?ContentTypeID=1</link><pubDate>Sun, 10 May 2009 23:30:13 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0b21047e-64e8-43a7-a71e-064d812cbd4b</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
groovy!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does it is Possible to Erase &amp; Write Sector 0 in LPC2214</title><link>https://community.arm.com/thread/144602?ContentTypeID=1</link><pubDate>Sun, 10 May 2009 21:18:10 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5861d318-ef7f-4b80-90b5-566f4ec1182f</guid><dc:creator>Mustafa Shaikh</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks Tamir &amp;amp; John .........&lt;/p&gt;

&lt;p&gt;
I am very happy by the advice suggested by you .......&lt;br /&gt;
really .... Just changing the code here and there had not help me
.... I have gone through the whole code with conceptually and through
understanding .......&lt;/p&gt;

&lt;p&gt;
Finally I was able to write the full IAP routine successfully
..... .i.e able to erase all the sectors &amp;amp; programmed
it......&lt;/p&gt;

&lt;p&gt;
I am making mistake in placing the code in ROM region, after your
advice place the code in &lt;b&gt;IRAM&lt;/b&gt; region that write the flash in
RAM, right click on your C file, use options to select a RAM region
-&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does it is Possible to Erase &amp; Write Sector 0 in LPC2214</title><link>https://community.arm.com/thread/144600?ContentTypeID=1</link><pubDate>Mon, 04 May 2009 18:41:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2c8550ba-b52c-4bd2-9d81-713445316183</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Mustafa,&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;=&amp;gt; I have tired to erase sector 0, but It does not return
from the IAP_Execute (&amp;amp;IAP); &amp;lt;=&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Do you mean that, actually, you have never erased sector 0
successfully?&lt;/p&gt;

&lt;p&gt;
It does not return, then, do you know where is it? What is the
value of your Program Counter?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does it is Possible to Erase &amp; Write Sector 0 in LPC2214</title><link>https://community.arm.com/thread/142293?ContentTypeID=1</link><pubDate>Mon, 04 May 2009 06:32:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6348299e-096c-4e87-a1d1-7d19b276fc94</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
question remains: have you followed my advise? even if it does not
immediately fix the problem, at least you&amp;#39;ll have that out of th way.
you really need to UNDERSTAND what you are doing - changing here and
there is not going to bring you anywhere.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does it is Possible to Erase &amp; Write Sector 0 in LPC2214</title><link>https://community.arm.com/thread/139153?ContentTypeID=1</link><pubDate>Mon, 04 May 2009 04:45:25 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b7076fa6-fc23-4b8a-8db9-1fb3e2d59e72</guid><dc:creator>Mustafa Shaikh</dc:creator><description>&lt;p&gt;&lt;p&gt;
I have tired to erase sector 0, but It does not return from the
IAP_Execute (&amp;amp;IAP); function i.e the code in the RED ?&lt;/p&gt;

&lt;pre&gt;
int EraseSector (unsigned long adr) {
  unsigned long n;
  unsigned long int Cntr;

  n = GetSecNum(adr);

  IAP.cmd    = 50;
  IAP.par[0] = n;
  IAP.par[1] = n;
  IAP_Execute (&amp;amp;IAP);

    // call LED Blink function
    LEDBlink(ON);
   // Add Delay
  for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
  for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
    LEDBlink(OFF);
  for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
  for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);

  if (IAP.stat)
    {
     // call LED Blink function
     LEDBlink(ON);
     // Add Delay
    for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
    for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
     LEDBlink(OFF);
    for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
    for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
     return (1);
     }

  IAP.cmd    = 52;
  IAP.par[0] = n;
  IAP.par[1] = n;
  IAP.par[2] = CCLK;

     LEDBlink(ON);
  for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
  for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
     LEDBlink(OFF);
  for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
  for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);

  IAP_Execute (&amp;amp;IAP);
  &lt;b&gt;
  /* It does not execute below function if we try to erase sector 0 */
  &lt;/b&gt;
  &lt;b&gt;
    LEDBlink(ON);
  for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
  for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
    LEDBlink(OFF);
  for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
  for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
  &lt;/b&gt;

  if (IAP.stat)
   {
    // call LED Blink function
     LEDBlink(ON);
     // Add Delay
    for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
    for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
     LEDBlink(OFF);
    for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
    for(Cntr=0; Cntr&amp;lt;5000000; Cntr++);
     return (1);
   }

  return (0);
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does it is Possible to Erase &amp; Write Sector 0 in LPC2214</title><link>https://community.arm.com/thread/135755?ContentTypeID=1</link><pubDate>Wed, 29 Apr 2009 18:58:43 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:89b965bb-3402-4f90-bd41-156347e9bef0</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
Sorry, let me try again.&lt;/p&gt;

&lt;pre&gt;
int ProgramPage (unsigned long adr, unsigned long sz, unsigned char *buf) {
  unsigned long n;
  unsigned int Cntr;

#if SET_VALID_CODE != 0
  if (adr == 0) {
    n = *((unsigned long *)(buf + 0x00)) +
        *((unsigned long *)(buf + 0x04)) +
        *((unsigned long *)(buf + 0x08)) +
        *((unsigned long *)(buf + 0x0C)) +
        *((unsigned long *)(buf + 0x10)) +
        *((unsigned long *)(buf + 0x18)) +
        *((unsigned long *)(buf + 0x1C));
        *((unsigned long *)(buf + 0x14)) = 0 - n;
  }
#endif

  n = GetSecNum(adr);

  IAP.cmd    = 50;
  IAP.par[0] = n;
  IAP.par[1] = n;
  IAP_Execute (&amp;amp;IAP);&lt;b&gt;
  if (IAP.stat) return (1);

/* IAP.stat provides all the information about why you can not write to sector 0. */
&lt;/b&gt;

  for(Cntr=0; Cntr&amp;lt;50000; Cntr++);
  for(Cntr=0; Cntr&amp;lt;50000; Cntr++);

  IAP.cmd    = 51;
  IAP.par[0] = adr;
  IAP.par[1] = (unsigned long)buf;
  IAP.par[2] = 1024;
  IAP.par[3] = CCLK;
  IAP_Execute (&amp;amp;IAP);&lt;b&gt;
  if (IAP.stat) return (1);

/* IAP.stat provides all the information about why you can not write to sector 0. */
&lt;/b&gt;

  for(Cntr=0; Cntr&amp;lt;50000; Cntr++);
  for(Cntr=0; Cntr&amp;lt;50000; Cntr++);
  return (0);
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does it is Possible to Erase &amp; Write Sector 0 in LPC2214</title><link>https://community.arm.com/thread/125407?ContentTypeID=1</link><pubDate>Wed, 29 Apr 2009 18:53:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7e05db54-5663-42cb-af80-a93128d0ef4a</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Mustafa,&lt;/p&gt;

&lt;p&gt;
You told us that, you can erase sector 0, but can not write to
sector 0. Then, you should check the Return Code of IAP Copy RAM to
flash command.&lt;/p&gt;

&lt;p&gt;
It means, what is &lt;b&gt;the value of your IAP.stat&lt;/b&gt; after you
execute the IAP Copy RAM to flash command?&lt;/p&gt;

&lt;pre&gt;
int ProgramPage (unsigned long adr, unsigned long sz, unsigned char *buf) {
  unsigned long n;
  unsigned int Cntr;

#if SET_VALID_CODE != 0
  if (adr == 0) {
    n = *((unsigned long *)(buf + 0x00)) +
        *((unsigned long *)(buf + 0x04)) +
        *((unsigned long *)(buf + 0x08)) +
        *((unsigned long *)(buf + 0x0C)) +
        *((unsigned long *)(buf + 0x10)) +
        *((unsigned long *)(buf + 0x18)) +
        *((unsigned long *)(buf + 0x1C));
        *((unsigned long *)(buf + 0x14)) = 0 - n;
  }
#endif

  n = GetSecNum(adr);

  IAP.cmd    = 50;
  IAP.par[0] = n;
  IAP.par[1] = n;
  IAP_Execute (&amp;amp;IAP);&lt;b&gt;
  if (IAP.stat) return (1);

/* IAP.stat provides all the information about why you can not write to sector 0. */

&lt;/b&gt;
  for(Cntr=0; Cntr&amp;lt;50000; Cntr++);
  for(Cntr=0; Cntr&amp;lt;50000; Cntr++);

  IAP.cmd    = 51;
  IAP.par[0] = adr;
  IAP.par[1] = (unsigned long)buf;
  IAP.par[2] = 1024;
  IAP.par[3] = CCLK;
  IAP_Execute (&amp;amp;IAP);
  if (IAP.stat) return (1);

  for(Cntr=0; Cntr&amp;lt;50000; Cntr++);
  for(Cntr=0; Cntr&amp;lt;50000; Cntr++);
  return (0);
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does it is Possible to Erase &amp; Write Sector 0 in LPC2214</title><link>https://community.arm.com/thread/114878?ContentTypeID=1</link><pubDate>Wed, 29 Apr 2009 05:57:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3b992b19-e6aa-40f3-9c5b-fee0750bae74</guid><dc:creator>Mustafa Shaikh</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks Tamir,&lt;/p&gt;

&lt;p&gt;
I have done following modification in my code &amp;amp; checked again
but the condition is same ? not able to write on sector 0 ?&lt;/p&gt;

&lt;pre&gt;
; Memory Mapping (when Interrupt Vectors are in RAM)

MEMMAP   EQU     0xE01FC040    ; Memory Mapping Control
         IF      :DEF:REMAP
         LDR      R0, =MEMMAP
  ;        IF     :DEF:EXTMEM_MODE
  ;        MOV    R1, #3
  ;        ELIF   :DEF:RAM_MODE
         IF       :DEF:RAM_MODE
         MOV      R1, #2
         ELSE
         MOV      R1, #1
         ENDIF
         STR      R1, [R0]
         ENDIF

&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does it is Possible to Erase &amp; Write Sector 0 in LPC2214</title><link>https://community.arm.com/thread/103078?ContentTypeID=1</link><pubDate>Wed, 29 Apr 2009 05:42:40 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e7e43df6-281b-4c6b-a631-b919cbef2478</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
first of all, settting MEMMAP where you did has no effect. it is
best to use following macroes in the ASM tab preprocessor textbox:
RAM_INTVEC REMAP RAM_MODE&lt;br /&gt;
second, you need to place the code that write the flash in RAM, not
only the interrupt service routines! right click on your C file, use
options to select a RAM region - or use your scatter file.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does it is Possible to Erase &amp; Write Sector 0 in LPC2214</title><link>https://community.arm.com/thread/101811?ContentTypeID=1</link><pubDate>Wed, 29 Apr 2009 05:36:41 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f9490d95-e904-430c-bcb9-62adf4f2b059</guid><dc:creator>Mustafa Shaikh</dc:creator><description>&lt;p&gt;&lt;p&gt;
Still I am not able to write on Sector 0 ?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does it is Possible to Erase &amp; Write Sector 0 in LPC2214</title><link>https://community.arm.com/thread/77406?ContentTypeID=1</link><pubDate>Wed, 29 Apr 2009 05:35:39 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:99945c66-e36b-4a56-9f27-11da223335ba</guid><dc:creator>Mustafa Shaikh</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks Tamir,&lt;/p&gt;

&lt;p&gt;
I have checked by placeing my programming code in RAM. As you can
see I have setted MEMMAP = 0x02;&lt;/p&gt;

&lt;pre&gt;
int Init (unsigned long adr, unsigned long clk, unsigned long fnc)
{
  unsigned int Cntr;
  CCLK  =  (1049*(clk &amp;gt;&amp;gt; 10)) &amp;gt;&amp;gt; 10;
//  PLLCON  = 0x00;
//  PLLFEED = 0xAA;
//  PLLFEED = 0x55;

  &lt;b&gt;MEMMAP  = 0x02; &lt;/b&gt;

  for(Cntr=0; Cntr&amp;lt;50000; Cntr++);
  for(Cntr=0; Cntr&amp;lt;50000; Cntr++);

  return (0);
}


&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does it is Possible to Erase &amp; Write Sector 0 in LPC2214</title><link>https://community.arm.com/thread/55951?ContentTypeID=1</link><pubDate>Wed, 29 Apr 2009 04:53:46 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5addc5d9-91d0-4ff8-8175-b922cb0c496e</guid><dc:creator>Tamir Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
I don&amp;#39;t know you processor, but maybe your program is running from
sector 0? did you try to place your programming code in RAM?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>