IAP on LPC1769

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IAP on LPC1769

2,420 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by masterboy on Tue Mar 19 06:09:18 MST 2013
Hi,

I try IAP on LPC1769. I would like to use last 4 sectors (26, 27, 28, 29) to store data. I have this simple examle:

#ifdef __USE_CMSIS
#include "LPC17xx.h"
#endif

#include <cr_section_macros.h>
#include <NXP/crp.h>

__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

#define IAP_LOCATION 0x1FFF1FF1

unsigned int command[5];
unsigned int result[5];

typedef void (*IAP)(unsigned int [],unsigned int[]);
IAP iap_entry;

int main(void) {

SystemCoreClockUpdate();

command[0] = 50;
command[1] = 26;
command[2] = 26;
iap_entry (command,result);

while(1) {

}
return 0 ;
}


I upload this code to LPC, but after start code stopped on HardFault_Handler. What does it mean? What do I do wrong?
0 Kudos
Reply
11 Replies

1,546 Views
sai_sankar_rao
Contributor I

Setting function pointer:
"iap_entry=(IAP) IAP_LOCATION;"

is missed in the code
write this before main.

0 Kudos
Reply

2,165 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wrighflyer on Thu Mar 21 08:55:59 MST 2013

Quote: user manual
SRC_ADDR_NOT_MAPPED Source address is not mapped in the memory map. Count value is taken in to consideration where applicable.


Just wonderin' but if you made msg[] a global with an align attribute rather than just letting it be created anywhere on the stack would it help?
0 Kudos
Reply

2,165 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Mar 21 08:53:02 MST 2013
That's answered in #4 of http://knowledgebase.nxp.com/showthread.php?t=4286 :eek:
0 Kudos
Reply

2,165 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by masterboy on Thu Mar 21 08:51:42 MST 2013
I know what is code 4 means (SRC_ADDR_NOT_MAPPED) but I dont understand why :(
0 Kudos
Reply

2,165 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Mar 21 08:07:33 MST 2013
Then look in your UM and see what this return code is trying to tell you :)
0 Kudos
Reply

2,165 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by masterboy on Thu Mar 21 07:57:53 MST 2013
What is wrong now (lpc1347)?

#ifdef __USE_CMSIS
#include "LPC13Uxx.h"
#endif

#include <cr_section_macros.h>
#include <NXP/crp.h>

__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

#define IAP_LOCATION 0x1fff1ff1
#define ADDRESS0xC000

typedef void (*IAP)(uint32_t [],uint32_t []);
IAP iap_entry = (IAP) IAP_LOCATION;

int main(void) {

uint32_t command[5];
uint32_t result[4];

uint8_t msg[] = "TEST IAP";

// *** PREPARE SECTOR 12
command[0] = 50;
command[1] = 12;
command[2] = 12;
iap_entry(command, result);
// *** ERASE SECTOR 12
command[0] = 52;
command[1] = 12;
command[2] = 12;
command[3] = SystemCoreClock / 1000;
iap_entry(command, result);
// *** PREPARE SECTOR 12
command[0] = 50;
command[1] = 12;
command[2] = 12;
iap_entry(command, result);
// *** COPY RAM TO FLASH
command[0] = 51;
command[1] = (uint32_t)ADDRESS;
command[2] = (uint32_t)&msg;
command[3] = 256;
command[4] = SystemCoreClock / 1000;
iap_entry(command, result);

while(1) {
}
return 0 ;
}


Last command "COPY RAM TO FLASH" return code 4, why?
0 Kudos
Reply

2,165 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kendwyer on Wed Mar 20 08:36:35 MST 2013
As suggested you should look at a working example, there is one posted here on LPCware.com:
http://www.lpcware.com/content/nxpfile/an11071-application-programming-lpc1700
Note the IAP for the LPC1769 will be the same for LPC176x
0 Kudos
Reply

2,165 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by masterboy on Tue Mar 19 11:00:28 MST 2013
You have right, function pointer setting is missing in my code. Where does it place in my code?
0 Kudos
Reply

2,165 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Mar 19 09:15:28 MST 2013

Quote: masterboy
I proceed by UM10360



No, where's your function pointer setting :confused:

Page 631:

Quote:

Setting function pointer:
[COLOR=Red]iap_entry=(IAP) IAP_LOCATION;[/COLOR]


Quote: masterboy
I dont know what is nonsense because it is writen on page 631



Without function pointer setting you are calling function of address 0 :eek:

That's nonsense and therefore you get a hard fault :p

Why don't you copy a working sample :confused:
0 Kudos
Reply

2,165 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by masterboy on Tue Mar 19 09:01:01 MST 2013
I proceed by UM10360. I dont know what is nonsense because it is writen on page 631 :(
0 Kudos
Reply

2,165 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Mar 19 06:38:44 MST 2013

Quote: masterboy
What do I do wrong?



Just copy a working sample ;) That's IAP thread 1000 in this forum :eek:


Quote: masterboy
Hi,
#define IAP_LOCATION 0x1FFF1FF1

unsigned int command[5];
unsigned int result[5];

[COLOR=Red]typedef void (*IAP)(unsigned int [],unsigned int[]);[/COLOR]
[COLOR=Red]IAP iap_entry;[/COLOR]



That's nonsense :eek:
0 Kudos
Reply