lpcware

IAP not to work?

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by LeonCorleone on Sat Feb 07 11:13:22 MST 2015
Hello all
I don't know what to do with this big problem.
If you can please help me.I takes me too much.   :(
I want to write some data from Sram into flash by IAP. Actually I don't know why IAP doesn't work in debug mode of Keil?In debug it doesn't write anything into flash.
my code is the same as below.
thanks. :)

#include <lpc17xx.h>//lpc17xx.h
#include <absacc.h>/absacc.h

unsigned char IAP_Write(unsigned char *string);
unsigned char a[5] __at(0x10000200);

#define IAP_ADDRESS  0x1FFF1FF1
unsigned int command[5];
unsigned int result[5];
typedef unsigned int (*IAP)(unsigned int[], unsigned int[]);
static const IAP iap_entry = (IAP) IAP_ADDRESS;

int main(void)
{
unsigned char i=0;

for(i=0;i<5;i++)
a=i;
IAP_Write(a);
}
unsigned char IAP_Write(unsigned char *string)
{
command[0]=50;
command[1]=8;  //Start sector number is 8
command[2]=8;  //Finish sector number is 8
  iap_entry(command,result);
if(result[0]!=0)
{
return 0;
}
command[0]=51;
command[1]=0x00008100;  //Addrees of Flash
command[2]=0x10000200;  //Addrees of Sram
command[3]=256;  //How many bytes want to transfer
command[4]=12000;  //Frequency in khz
iap_entry(command,result);
if(result[0]!=0)
{
return 0;
}
else
{
return 1;
}
}

Outcomes