Forums

2138 iap problem

Started by good...@acanac.net August 28, 2008
Hi,
I am experiencing troubles with iap fucntions for the LPC2138.

The code executes correctly with no error status and the bootversion
and Chip ID codes it returns are correct, however the flash is not
updated. (Not erased nor writtten).

The bootversion is 2.12 , i am using Rowley Crossworks with GCC ,
interrupts are disabled while using iap, switching to thumb mode is
done correctly. I don t see what s wrong. The chip can programmed is
ISP using the flash utiliy withouit problems. I tested with a demo
borad from keil with the same results.
I also tested the MCB 2130 demo board with a demo example in the keil
directory and it s doing the same thing; works in ISP but in IAP thje
flash dpes nt change.
Please any help.
Essaid Haddadou
Concepteur Electronique/Electronic Designer
2396 de la province, Longueuil J4G 1G1
450 442 7887 ext 247

An Engineer's Guide to the LPC2100 Series

Are you preparing the sectors before each erase or write function? Are the
buffers on a word boundary? Is the size of the transfer buffers correct?
What are you using for code? Can you show us what you are doing??
Thanks,
Mike


Yes i am doing that.
the demo code from keil in C:\Keil\ARM\Boards\Keil\MCB2100\IAP is behaving the same way.

Here is what i am using:

#define IAP_LOCATION (0x7ffffff1)
#define IAP_CMD_PREPARE (50)
#define IAP_CMD_COPYRAMTOFLASH (51)
#define IAP_CMD_ERASE (52)
#define IAP_CMD_BLANKCHECK (53)
#define IAP_CMD_READPARTID (54)
#define IAP_CMD_READBOOTCODEVER (55)
#define IAP_CMD_COMPARE (56)
s16 iapEraseSectors (s16 startingSector, s16 endingSector)
{
u16 cpsr;

if (!iapIsSafeSector (startingSector) || !iapIsSafeSector (endingSector))
return -1;

if (iapPrepareSectors (startingSector, endingSector) == -1)
return -1;

u16IapCommands [0] = IAP_CMD_ERASE;
u16IapCommands [1] = startingSector;
u16IapCommands [2] = endingSector;
u16IapCommands [3] = CPUCLK_IN_KHZ;

cpsr = disableInts ();

iapCall ();

restoreInts (cpsr);

return ((s16IapErrno = u16IapResults [0]) == IAP_RESULT_CMD_SUCCESS) ? 0 : -1;
}

static void iapCall (void) __attribute ((naked));
static void iapCall (void)
{
register void *pFP0 asm("r0") = u16IapCommands;
register void *pFP1 asm("r1") = u16IapResults;

asm volatile(" bx %[iapLocation]"
:
: "r" (pFP0), "r" (pFP1), [iapLocation] "r" (IAP_LOCATION) );
}

Hi,
> I am experiencing troubles with iap fucntions for the LPC2138.
>
> The code executes correctly with no error status and the bootversion
>and Chip ID codes it returns are correct, however the flash is not
>updated. (Not erased nor writtten).
>
>The bootversion is 2.12 , i am using Rowley Crossworks with GCC ,
>interrupts are disabled while using iap, switching to thumb mode is
>done correctly. I don t see what s wrong. The chip can programmed is
>ISP using the flash utiliy withouit problems. I tested with a demo
>borad from keil with the same results.
>I also tested the MCB 2130 demo board with a demo example in the keil
>directory and it s doing the same thing; works in ISP but in IAP thje
>flash dpes nt change.
>Please any help.
>Essaid Haddadou
>Concepteur Electronique/Electronic Designer
>2396 de la province, Longueuil J4G 1G1
>450 442 7887 ext 247
>
>
Additional information: I am using a 10 MHZ clock (sending 10000 as a parameter for cclk) the PLL is disabled.