Hi, i have problem using IAP to program full flash memory. I have found an example in the LPC INSIDE'R GUIDE but the Keil compiler can't compile. This is the code and the compiler output:
#include <LPC22xx.H>
typedef void (*IAP)(unsigned int [],unsigned int []); IAP iap_bypointer; void iap_byfunction (unsigned *cmd,unsigned *rslt,unsigned entry);
unsigned command[5]; unsigned result[5]; char Ram_Arry[] = "Hello World"; char *Ram_Pointer;
/////// LINE 13 //////////// int main (void) __arm //Compile this in ARM instruction set { unsigned char index;
iap_bypointer = (IAP) 0x7FFFFFF1; //set IAP entry address in function pointer
//////////// LINE 19 ///////////////// Ram_Pointer = 0x40000100; //Set pointer to RAM for (index = 0; index<0x0B; index++) //Copy data to be written to flash into the RAM { *Ram_Pointer = Ram_Arry[index]; Ram_Pointer++; }
command[0] = 0x36; //command code for "Read part ID" iap_byfunction(command,result,0x7FFFFFF0); //Call IAP functions by function method
command[0] = 50; //Prepare sector five for a write operayion command[1] = 5; command[2] = 5; iap_bypointer(command,result);
command[0] = 51; //write 512 bytes from address 0x40000100 command[1] = 0x0000A000; //to 0x0000A000 in flash memory; command[2] = 0x40000100; command[3] = 512; command[4] = 12000; // see erase comment above iap_byfunction(command,result,0x7FFFFFF0);
while(1) {;}
}
///// LINE 45 ////// void iap_byfunction (unsigned *cmd,unsigned *rslt,unsigned entry) __thumb //compile this in Thumb instruction set __asm { mov r15,r2; } //////// LINE 47 //////// //move entry address into PC
Build target 'Target 1' assembling Startup.s... compiling main.c... main.c(13): error: #130: expected a "{" main.c(19): error: #513: a value of type "int" cannot be assigned to an entity of type "char *" main.c(45): error: #130: expected a "{" main.c(47): error: #20: identifier "r15" is undefined main.c(47): warning: #1267-D: Implicit physical register R2 should be defined as a variable main.c(47): error: #549: variable "R2" is used before its value is set Target not created
Can somebody please help me why the compiler can't do this if it's ok.
Thanks. Yaque.
View all questions in Keil forum