完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
测试代码如下:
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"); 结果打印: 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的示例代码也是这个结果,反而EEPROM_READ操作可以读到0xFFFFFFFF。 连续两次写入相同地址后,并没有相与的效果,貌似做了擦除后重新写入的,这样每写一个字节就扇区擦除一次是否会缩短寿命? |
|
相关推荐
1个回答
|
|
因为Flash是加扰的,只擦以后,flash实际是0xffffffff,但是经过内核加扰读出来是0xF5F9BDA9,目的是为了防止flash内容被简单读取。造成固件被盗取。flash可以校验。
dataflash是不加扰的 |
|
|
|
只有小组成员才能发言,加入小组>>
525 浏览 1 评论
CH579M+RT-Thread,RTC从Sleep模式唤醒失败是什么原因?
2904 浏览 2 评论
2400 浏览 1 评论
872浏览 2评论
691浏览 1评论
riscv-none-embed-objcopy: \'PWM_Output.elf\': No such file这个咋解决,
420浏览 1评论
534浏览 1评论
请教一下,Mounriver 编译不成功:找不到库文件,怎么整
816浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-26 05:13 , Processed in 1.273777 second(s), Total 78, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号