2016-01-29 03:50 AM
I'm trying to flash memory using stm32f10x_flash library. here the code:
/*in the arm-gcc-link.ld file i added this lines to allocate rom memory for my data*/.dataconf 0x0807F000: { KEEP(*(.ROMDATA)) *(.dataconf*) } > rom/*I declared this in the main.c to allocate rom memory */const uint16_t Pat __attribute__((section (''.ROMDATA'')));/* finally the function to flash memory (always in main.c) */void FlashMemory(void){ uint16_t IDPat = 1; FLASH_Status FlashStat; FLASH_Unlock(); FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR); FlashStat = FLASH_ProgramHalfWord(0x0807F000, IDPat); FLASH_Lock();}FlashStat is FLASH_ERROR_PG. can you tell me what it means and where is the error?2016-01-29 03:59 AM
You missed erasing the page before programming. FLASH_ErasePage(flashaddress)
Also, a hardfault will occur, if you do un-alligned flash write.2016-01-29 04:04 AM
Also, I don't know much about linker scripts, but you might be trying to write into a memory which you are here setting as Read-only (ROMDATA ?)
2016-01-29 05:13 AM
problem solved, thanks ;)