请问为什么FLASH擦除后不能写

2019-07-20 05:29发布

[mw_shl_code=c,true] if(number<12) { FLASH_Unlock(); FLASH_DataCacheCmd(DISABLE);//FLASH擦除期间,必须禁止数据缓存 //FLASH_EraseSector(STMFLASH_GetFlashSector(0x08040000+number*0x800),VoltageRange_3);//VCC=2.7~3.6V之间!! for(temp=0;temp<1024;temp++) { appoint_address=0x08040000+number*0x800+temp*2; wait_write=prog_write_buffer[temp*2]+prog_write_buffer[temp*2+1]*0X100; FLASH_ProgramHalfWord(appoint_address,wait_write); } FLASH_DataCacheCmd(ENABLE); //FLASH擦除结束,开启数据缓存 FLASH_Lock(); } }[/mw_shl_code] [mw_shl_code=c,true]请问为什么FLASH擦除后不能写[/mw_shl_code] [mw_shl_code=c,true]0x08040000初始化为0xFFFF注释擦除代码就可以写,不注释擦除代码就不能写了[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
6条回答
逆行者
2019-07-20 17:21
[mw_shl_code=c,true]都擦了就是写不进,初始化为0xFFFF,但不擦除就可以写,擦了就不能写了[/mw_shl_code] [mw_shl_code=c,true]void write_block(u16 number) {u16 temp,wait_write; u32 appoint_address; if(number<12) { FLASH_Unlock(); FLASH_DataCacheCmd(DISABLE);//FLASH擦除期间,必须禁止数据缓存 FLASH_EraseSector(STMFLASH_GetFlashSector(flash_start_address+number*0x800),VoltageRange_3);//VCC=2.7~3.6V之间!! for(temp=0;temp<1024;temp++) { appoint_address=flash_start_address+number*0x800+temp*2; wait_write=prog_write_buffer[temp*2]+prog_write_buffer[temp*2+1]*0X100; FLASH_ProgramHalfWord(appoint_address,wait_write); } FLASH_DataCacheCmd(ENABLE); //FLASH擦除结束,开启数据缓存 FLASH_Lock(); } }[/mw_shl_code]


一周热门 更多>