2011-07-20 05:12 AM
Hello,
in my application I use a part of the flash (0x8007C00 ... 0x8008000) as memory for my own data. I's all ok when I locate the application at address 0x8000000, but when I locate my application to address 0x8003000 the flash programming goes wrong, after the command ''erase page'' (FLASH->CR |= CR_STRT_Set) the system hangs. Can anybody help me to solve this problem? Regards, Gert. #stm32-flash2011-07-20 07:10 AM
Probably your program is longer than 19456 bytes (0x4C00) and you are erasing part of it.
You need to check the occupied address range from the linker listing.2011-07-20 07:51 AM
The last address of my application is 0x80072b4. This error occurs also when I use another flash range e.g. 0x8002C00.
Regards, Gert.2011-07-20 08:45 AM
Can anybody help me to solve this problem?
Sure, what's your contractor rate? You have provided insufficient information/code to give a clear diagnosis, so let's just guess. You're touching memory in an inappropriate way, and the system is Hard Faulting. Did you move the vector table address when your application moved to 0x08003000? Do you have a Hard Fault handler to catch failures? Have you single stepped at an instruction level with a JTAG debugger? Have you checked the memory window for the data area in question? What's the flash page size for the part you are using? Post some more complete code for the flash routine, may be there are some obvious issues there.
2011-07-21 11:20 PM
I have move the vector table address to the range where my application is run and I have also a hard fault handler. The flash page size is 1kByte. Now I have comment out the flash page erase command, because no hard fault handler was called and the JTAG debugger was hanging.
The next step, I tried, was programm the flash. Now the hard fault handler was called, when I try to write at the flash (no matter which flash range I use). FLASH_Status ProgramWord(uint32_t Address, uint32_t Data) { FLASH_Status status = FLASH_COMPLETE; __IO uint32_t tmp = 0; /* Wait for last operation to be completed */ status = WaitForLastOperation(ProgramTimeout); if(status == FLASH_COMPLETE) { /* if the previous operation is completed, proceed to program the new first half word */ FLASH->CR |= CR_PG_Set; *(__IO uint16_t*)Address = (uint16_t)Data; // after this command, hard fault handler called /* Wait for last operation to be completed */ status = WaitForLastOperation(ProgramTimeout); if(status == FLASH_COMPLETE) { /* if the previous operation is completed, proceed to program the new second half word */ tmp = Address + 2; *(__IO uint16_t*) tmp = Data >> 16; /* Wait for last operation to be completed */ status = WaitForLastOperation(ProgramTimeout); /* Disable the PG Bit */ FLASH->CR &= CR_PG_Reset; } else { /* Disable the PG Bit */ FLASH->CR &= CR_PG_Reset; } }2011-07-22 05:32 AM
The flash problem is solved.
2014-03-28 05:35 AM
I have the same issue , please tell us how to solve this problem..
2014-03-28 06:00 AM
Hi
''I have the same issue , please tell us how to solve this problem..'' Start a new thread and give us details about your problems. If you can (ie no commercial code) - post your code for us to inspect. My initial thoughts are : look carefully where your Flash programming code is located (which Flash Sector) and which sector the code is trying to erase/program!