用的是ST的固件库编程,部分代码如下:
FLASH_SetProgrammingTime(FLASH_PROGRAMTIME_STANDARD);
/* Unlock Data memory */
FLASH_Unlock(FLASH_MEMTYPE_DATA);
/* Fill the buffer in RAM */
for (i = 0; i < FLASH_BLOCK_SIZE; i++) GBuffer = new_val2;
/* Program the block 0*/
block = 0; /* block 0 is first block of Data memory: address is 0x4000 */
FLASH_ProgramBlock(block, FLASH_MEMTYPE_DATA, FLASH_PROGRAMMODE_STANDARD, GBuffer);
FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
编译没问题,点运行不报错,就是程序一直处于运行状态,点暂停的时候会出现遇到无效参数的提示,程序死机,重新编译运行,用单步发现程序在FLASH_ProgramBlock(block, FLASH_MEMTYPE_DATA, FLASH_PROGRAMMODE_STANDARD, GBuffer);
这里有问题,报错Stop...Error: swim prog error [42004]: memory write error
不知道是什么问题 |