IAP Erase operation

Started by gogotimmo August 11, 2006
Hi Everyone-

I'm getting frustrated with the IAP implementation on the LPC2138.
I've followed the application note describing how to make the
function calls from C, and that part seems to be working. For
example, if I try to erase a sector I first call the IAP function
with command 50 (Prepare Sector) and it returns CMD_SUCCESS as
expected. Next, I call IAP with command 52 (Erase Sector) with
sector 4 as the start and stop sector, and it returns CMD_SUCCESS.
Great! Then, however, I call OAP with command 53 (Blank Check) and
it returns SECTOR_NOT_BLANK. So, even though the erase command
returns a success, the sector does NOT get erased? It seems the IAP
call is working because it jumps into the boot code area and returns
with modification to the result codes, but the erase is not working.
Without being able to single step the IAP code, I have no idea what
is wrong. I've reserved the top 32 bytes of SRAM as suggested. What
is the comment in the manual about 128 bytes of user stack? Do I
have to implement a stack at a specific location? Right now it is
near the bottom of ram space. I've also read that MAM might need to
be configured in a special way. Any ideas will help.

Thanks-
Tim

An Engineer's Guide to the LPC2100 Series

--- In l..., "gogotimmo" wrote:
>
> Hi Everyone-
>
> I'm getting frustrated with the IAP implementation on the LPC2138.
> I've followed the application note describing how to make the
> function calls from C, and that part seems to be working. For
> example, if I try to erase a sector I first call the IAP function
> with command 50 (Prepare Sector) and it returns CMD_SUCCESS as
> expected. Next, I call IAP with command 52 (Erase Sector) with
> sector 4 as the start and stop sector, and it returns CMD_SUCCESS.
> Great! Then, however, I call OAP with command 53 (Blank Check) and
> it returns SECTOR_NOT_BLANK. So, even though the erase command
> returns a success, the sector does NOT get erased? It seems the IAP
> call is working because it jumps into the boot code area and returns
> with modification to the result codes, but the erase is not working.
> Without being able to single step the IAP code, I have no idea what
> is wrong. I've reserved the top 32 bytes of SRAM as suggested. What
> is the comment in the manual about 128 bytes of user stack? Do I
> have to implement a stack at a specific location? Right now it is
> near the bottom of ram space. I've also read that MAM might need to
> be configured in a special way. Any ideas will help.
>
> Thanks-
> Tim
>

Tim, are you doing this with sector 0? Note that IAP implementation
is unaware of memory mapping on LPC and thus erase and blank check on
sector 0 can fail.

Hope this helps.

Jaya
Unfortunately, I wish it was that easy. I am trying to erase sectors
4 and higher.

--- In l..., "jayasooriah"
wrote:
>
> --- In l..., "gogotimmo" wrote:
> >
> > Hi Everyone-
> >
> > I'm getting frustrated with the IAP implementation on the
LPC2138.
> > I've followed the application note describing how to make the
> > function calls from C, and that part seems to be working. For
> > example, if I try to erase a sector I first call the IAP
function
> > with command 50 (Prepare Sector) and it returns CMD_SUCCESS as
> > expected. Next, I call IAP with command 52 (Erase Sector) with
> > sector 4 as the start and stop sector, and it returns
CMD_SUCCESS.
> > Great! Then, however, I call OAP with command 53 (Blank Check)
and
> > it returns SECTOR_NOT_BLANK. So, even though the erase command
> > returns a success, the sector does NOT get erased? It seems the
IAP
> > call is working because it jumps into the boot code area and
returns
> > with modification to the result codes, but the erase is not
working.
> > Without being able to single step the IAP code, I have no idea
what
> > is wrong. I've reserved the top 32 bytes of SRAM as suggested.
What
> > is the comment in the manual about 128 bytes of user stack? Do I
> > have to implement a stack at a specific location? Right now it
is
> > near the bottom of ram space. I've also read that MAM might need
to
> > be configured in a special way. Any ideas will help.
> >
> > Thanks-
> > Tim
> > Tim, are you doing this with sector 0? Note that IAP
implementation
> is unaware of memory mapping on LPC and thus erase and blank check
on
> sector 0 can fail.
>
> Hope this helps.
>
> Jaya
>
--- In l..., "gogotimmo" wrote:
>
> Unfortunately, I wish it was that easy. I am trying to erase sectors
> 4 and higher.

Have you tried reading sector 4 to check if it was indeed erased?

Try specifying a clock frequency that is 10 percent higher if the IAP
erase operation is the culprit.

Hope this helps.

Jaya
Even though the erase command returns success, the blank check command
fails. If I look at memory with a debugger, it is indeed not erased. I
have no idea what theissue is. I am already running close to 60MHz. I
tried turning off the PLL and MAM, but it didn't help. It doesn't
crash like what most people with problems experience. It seems to
execute the IAP and return, but just doesn't erase.

--- In l..., "jayasooriah" wrote:
>
> --- In l..., "gogotimmo" wrote:
> >
> > Unfortunately, I wish it was that easy. I am trying to erase
sectors
> > 4 and higher.
>
> Have you tried reading sector 4 to check if it was indeed erased?
>
> Try specifying a clock frequency that is 10 percent higher if the IAP
> erase operation is the culprit.
>
> Hope this helps.
>
> Jaya
>
--- In l..., "gogotimmo" wrote:
>
> Even though the erase command returns success, the blank check command
> fails. If I look at memory with a debugger, it is indeed not erased. I
> have no idea what theissue is. I am already running close to 60MHz. I
> tried turning off the PLL and MAM, but it didn't help. It doesn't
> crash like what most people with problems experience. It seems to
> execute the IAP and return, but just doesn't erase.

a) Does erase work in ISP mode?

b) When CPU is running 60 MHz, does erase work if param2 is 50,000?

If (a) works but (b) fails, I believe there is something clandestine
in your code :)

Good luck.

Jaya