測試代碼如下:
const uint32_t test_buf=0x30000-0x1000;
uint32_t *p;
??? printf("Erase...\n");
??????? FLASH_ROM_ERASE(test_buf, 4096);
??????? p=(uint32_t*)test_buf;
??????????????? printf("%8X,",*p); p++;
??????????????? printf("%8X,",*p); p++;
??????????????? printf("%8X,",*p); p++;
??????????????? printf("%8X,",*p); p++;
??????????????? printf("%8X,",*p); p++;
??????????????? printf("%8X,",*p); p++;
??????????????? printf("%8X,",*p); p++;
??????????????? printf("%8X,",*p); p++;
??????????????? printf("\n");
??? p=(uint32_t*)test_buf;
??? printf("write:\n");
??? p=(uint32_t*)test_buf;
??? dat=1;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
??? dat=2;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
??? dat=4;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
??? dat=8;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
??? dat=0x10;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
??? p=(uint32_t*)test_buf;
??????? printf("%8X,",*p); p++;
??????? printf("%8X,",*p); p++;
??????? printf("%8X,",*p); p++;
??????? printf("%8X,",*p); p++;
??????? printf("%8X,",*p); p++;
??????? printf("%8X,",*p); p++;
??????? printf("%8X,",*p); p++;
??????? printf("%8X,",*p); p++;
??????? printf("\n");
??? printf("write2:\n");
??? p=(uint32_t*)test_buf;
??? dat=2;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
??? dat=4;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
??? dat=8;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
??? dat=0x10;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
??? dat=0x20;FLASH_ROM_WRITE((uint32_t)p,&dat,4);p++;
??? p=(uint32_t*)test_buf;
??????? printf("%8X,",*p); p++;
??????? printf("%8X,",*p); p++;
??????? printf("%8X,",*p); p++;
??????? printf("%8X,",*p); p++;
??????? printf("%8X,",*p); p++;
??????? printf("%8X,",*p); p++;
??????? printf("%8X,",*p); p++;
??????? printf("%8X,",*p); p++;
??????? printf("\n");
結(jié)果打印:
Erase...
F5F9BDA9,F5F9BDA9,F5F9BDA9,F5F9BDA9,F5F9BDA9,F5F9BDA9,F5F9BDA9,F5F9BDA9,
write:
?????? 1,?????? 2,?????? 4,?????? 8,????? 10,F5F9BDA9,F5F9BDA9,F5F9BDA9,
write2:
?????? 2,?????? 4,?????? 8,????? 10,????? 20,F5F9BDA9,F5F9BDA9,F5F9BDA9,
為什么flash擦除后讀取到的不是0xffffffff而是F5F9BDA9 ?燒錄EVT的示例代碼也是這個結(jié)果,反而EEPROM_READ操作可以讀到0xFFFFFFFF。
連續(xù)兩次寫入相同地址后,并沒有相與的效果,貌似做了擦除后重新寫入的,這樣每寫一個字節(jié)就扇區(qū)擦除一次是否會縮短壽命?