查看: 1070|回复: 0

SAM4L-EK FLASH读写、擦除操作

[复制链接]
  • TA的每日心情
    开心
    2016-3-22 09:25
  • 签到天数: 115 天

    连续签到: 1 天

    [LV.6]常住居民II

    发表于 2016-4-18 08:36:57 | 显示全部楼层 |阅读模式
    分享到:
    SAM4L-EK板载FLASH AT25DF64的主要特性特性如下:
    Features
    Single 2.7V - 3.6V Supply
    Serial Peripheral Interface (SPI) Compatible
    – Supports SPI Modes 0 and 3
    – Supports RapidS® Operation
    – Supports Dual-Input Program and Dual-Output Read
    Very High Operating Frequencies
    – 100 MHz for RapidS
    – 85 MHz for SPI
    – Clock-to-Output (tV) of 5 ns Maximum
    Flexible, Optimized Erase Architecture for Code + Data Storage Applications
    – Uniform 4-Kbyte Block Erase
    – Uniform 32-Kbyte Block Erase
    – Uniform 64-Kbyte Block Erase
    – Full Chip Erase
    Individual Sector Protection with Global Protect/Unprotect Feature
    – 128 Sectors of 64-Kbytes Each
    Hardware Controlled Locking of Protected Sectors via WP Pin
    Sector Lockdown
    – Make Any Combination of 64-Kbyte Sectors Permanently Read-Only
    128-Byte Programmable OTP Security Register
    Flexible Programming
    – Byte/Page Program (1 to 256 Bytes)
    Fast Program and Erase Times
    – 1.0 ms Typical Page Program (256 Bytes) Time
    – 50 ms Typical 4-Kbyte Block Erase Time
    – 250 ms Typical 32-Kbyte Block Erase Time
    – 400 ms Typical 64-Kbyte Block Erase Time
    Program and Erase Suspend/Resume
    Automatic Checking and Reporting of Erase/Program Failures
    Software Controlled Reset
    JEDEC Standard Manufacturer and Device ID Read Methodology
    Low Power Dissipation
    – 5 mA Active Read Current (Typical at 20 MHz)
    – 5 µA Deep Power-Down Current (Typical)
    Endurance: 100,000 Program/Erase Cycles
    Data Retention: 20 Years
    Complies with Full Industrial Temperature Range
    Industry Standard Green (Pb/Halide-free/RoHS Compliant) Package Options
    – 16-Lead SOIC (300-mil wide)
    – 8-Contact Very Thin DFN (6 x 8 mm)
    敲入如下的测试代码,对FLASH的操作作如下测试:
    1、擦除后FLASH内容是0x00还是0xFF ?
    2、擦除 - 写入 - 读出,查看数据是否正确写入?
    3、不擦除直接写入的情况下,读出数据查看数据是否正确写入?
    4、往FLASH的额定地址范围之外写入数据,结果如何?

    #define TEST_CASE1
    int main(void)
    {
       sysclk_init();
       board_init();
       at25dfx_initialize();
       at25dfx_set_mem_active(AT25DFX_MEM_ID);
       at25dfx_protect_chip(AT25_TYPE_UNPROTECT);
       uint8_t array[512];
       uint16_t n;
       for(n = 0;n < 512;n++) {
          array[n] = n;
       }
    #if TEST_CASE == 0 // 查看擦除之后的数据
       at25dfx_erase_block(128);
       at25dfx_read(array,512,128);
       asm("nop");
    #elif TEST_CASE == 1 // 是否正确写入
       at25dfx_erase_block(128);
       for(n = 0;n < 512;n++) {
       array[n] = n;
       }
       at25dfx_write(array,512,128);
       for(n = 0;n < 512;n++) {
       array[n] = 0;
       }
       at25dfx_read(array,512,128);
       asm("nop");
    #elif TEST_CASE == 2// 写入之前不擦除,是否能正确写入
       for(n = 0;n < 512;n++) {
       array[n] = n;
       }
       at25dfx_write(array,512,128);
       for(n = 0;n < 512;n++) {
       array[n] = 0;
       }
       at25dfx_read(array,512,128);
       asm("nop");
    #elif TEST_CASE == 3 // 往FLASH地址范围之外写
       at25dfx_erase_block(128);
       for(n = 0;n < 512;n++) {
       array[n] = n;
       }
       at25dfx_write(array,512,0x7FFFFF);
       for(n = 0;n < 512;n++) {
       array[n] = 0;
       }
       at25dfx_read(array,512,0x7FFFFF);
       asm("nop");
    #else
    #endif




    总结:
    1、AT25DF64擦除之后数据为0xFF
    2、AT25DF64在往某个地址写入数据前,必须执行擦除操作,否则不能正确写入
    3、往AT25DF64额定地址之外的地址写入数据,将出错
    4、AT25DF64的最大地址为0x7FFFFF,容量8Mbyte
    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /4 下一条

    手机版|小黑屋|与非网

    GMT+8, 2024-11-19 06:22 , Processed in 0.112251 second(s), 17 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.