سلام بچه ها
کس با IAP کار کرده یا نه
من می خوام داده ای رو از SRAM ببرم داخل یک فضایی از flash ذخیره کنم.همه چی درست کار می کنه ولی فقط نیمدونم چرا روتین IAP کار نمیکنه اگر کسی چیزی می دونه لطفا کمک کنه.
در ضمن [0]result همیشه صفر رو بر می گردونه اصلا کار نمیکنه.
اینم کدم.ممنون
کد:
#include <lpc17xx.h>
#include <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]=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;
}
}
}