我用的是K9F4G08U0M
每个block 第一次擦除写入都正常,但是再次擦除后,不能正常擦除,数据不变。请问原因是?大神门请指教
[mw_shl_code=c,true]void Flashearseblocktest(void)
{
uint8 ret,you[2048];
uint16 i;
ret = FlashEraseBlock(FLASH_BLOCK_TABLE_ADDR + FLASH_BLOCK_SIZE*0);
//nprintf(ret,0,HEX);
if(0x01== (ret & 0x01)) //如果擦除失败
{
stprintf("擦除失败");
}
//FlashReset();
OSTimeDly(OS_TICKS_PER_SEC/2);
IWDG_ReloadCounter();
//nprintf(FLASH_BLOCK_TABLE_ADDR + FLASH_BLOCK_SIZE*m,0,HEX);
FlashReadOnePage(FLASH_BLOCK_TABLE_ADDR + FLASH_BLOCK_SIZE*0,&mytest1[0],FLASH_PAGE_SIZE);///////////////////////////////
printf("mytest1[0]= 0x%x, mytest1[1]=0x%x, mytest1[2]=0x%x, mytest1[1536]=0x%x
",mytest1[0],mytest1[1],mytest1[2],mytest1[1536]);
for(i=0;i<FLASH_PAGE_SIZE;i++)
{
if(mytest1!=0xFF)
{
printf("mytest1[%d] = 0x%x
",i,mytest1);
}
IWDG_ReloadCounter();
}
IWDG_ReloadCounter();
#if 1
for(i=0;i<255;i++)
{
you=i;
}
FlashWriteOnePage(FLASH_BLOCK_TABLE_ADDR + FLASH_BLOCK_SIZE*0,&you[0],255);
FlashReadOnePage(FLASH_BLOCK_TABLE_ADDR + FLASH_BLOCK_SIZE*0,&mytest1[0],FLASH_PAGE_SIZE);
for(i=0;i<255;i++)
{
if(mytest1!= i)
{
printf("mytest1[%d] = %d
",i,mytest1);
}
IWDG_ReloadCounter();
}
printf("mytest1[0]= 0x%x, mytest1[1]=0x%x, mytest1[2]=0x%x, mytest1[1536]=0x%x
",mytest1[0],mytest1[1],mytest1[2],mytest1[1536]);
#endif
}[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>