Content originally posted in LPCWare by german on Mon Apr 19 00:08:35 MST 2010
Ok,
- debug_mem.ld -->
MEMORY
{
/* Define each memory region */
MFlash8 (rwx) : ORIGIN = 0x0, LENGTH = 0x0FFF /* 4k */
RamLoc4 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x800 /* 2k */
}
/* Define a symbol for the top of each memory region */
__top_MFlash8 = 0x0 + 0x0FFF;
__top_RamLoc4 = 0x10000000 + 0x800;
But I get --> n/ld.exe: region MFlash8 overflowed by 2809 bytes
collect2: ld returned 1 exit status
I'm using te optimization tool to maximun level.
It's not possible to restrict the flash rom use to a minor area than a full sector?
This is the code i'm using-->
#define SystemFrequency SystemCoreClock
#define PREP_WR 50
#define FLASH_WR 51
#define ERASE_SEC 52
#define FLASHSEC 1;
#define FLASHDIR 0x00001F00
/* Call into embedded utility. */
#define IAP_LOCATION 0x1fff1ff1
void write_nonvolatile_parameters(void){
/* First we will prepare the sector for erase. */
command[0] = PREP_WR;
command[1] = FLASHSEC;
command[2] = FLASHSEC;
iap_entry (command, result);
if (result[0] != 0) {
/* This is an error. */
result[0] = 0xff;
return;
}
/* Next we will erase the sector. */
command[0] = ERASE_SEC;
command[1] = FLASHSEC;
command[2] = FLASHSEC;
command[3] = SystemFrequency / 1000; /* Must be in terms of cycles per millisecond. */
command[4] = 0;
iap_entry (command, result);
if (result[0] != 0) {
/* This is an error. */
result[0] = 0xff;
return;
}
/* We will prepare the sector for write. */
command[0] = PREP_WR;
command[1] = FLASHSEC;
command[2] = FLASHSEC;
iap_entry (command, result);
if (result[0] != 0) {
/* This is an error. */
result[0] = 0xff;
return;
}
/* Then we will write the sector. */
command[0] = FLASH_WR;
command[1] = FLASHDIR;
command[2] = vRef; //extern volatile uint32_t vRef = 3300;
command[3] = 256;
command[4] = SystemFrequency / 1000; /* Must be in terms of cycles per millisecond. */
iap_entry (command, result);
if (result[0] != 0) {
/* This is an error. */
result[0] = 0xff;
return;
}
}
uint32_t read_nonvolatile_parameters(void)
{
unsigned long *add;
uint32_t value=0;
add=(unsigned long *)FLASHDIR;
value=*add;
}
I get this --> HardFault_Handler(void)