免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1204 | 回复: 0
打印 上一主题 下一主题

Flash erase/program 检查方法 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-06-29 16:45 |只看该作者 |倒序浏览
  注意:读本篇文章要对flash的操作有些基础知识,或者要找份datasheet来看看。
  
  有两种方法Data polling 和Toggle bit
  • Data Polling
    在erase/program
    cmd写下去之后,Q7位会变成data取反(因为erase后是0xff,所以这时Q7=0),然后直到erase/program操作结束,Q7才会
    变成实际的data。也就是flash进入普通的read模式。所以我们在写driver时,是可以使用 erase:
    while(*addr==0xff); program: while(*addr==data); 这样的方法来等待操作结束的。
  • Toggle Bit
    在erase/program cmd写下去之后, Q6位在连续的两次读操作中,读出的数据会相反,直到erase/program操作结束.参考这样一段代码
                   
                   
                    int FlashDataToggle( void )
    {
       volatile FLASH_DEF u1, u2; /* hold values read from any address offset within
                               the Flash Memory */
       volatile FLASH_DEF * pFA;
       while( 1 )  /* TimeOut!: If, for some reason, the hardware fails then this
                      loop may not exit. Use a timer function to implement a timeout
                      from the loop. */
       {
          /* Step 1: Read DQ6 (into a word) */
          pFA = FLASH_CAST(FLASH_ADRS);     /* Read DQ6 from the Flash (any address) */
          u1 = *pFA;
          /* Step 2: Read DQ5 and DQ6 (into another word) */
          u2 = *pFA; //FlashRead( ANY_ADDR );    /* Read DQ5 and DQ6 from the Flash (any
          /* Step 3: If DQ6 did not toggle between the two reads then return
                     FLASH_SUCCESS */
          if( (u1&0x40) == (u2&0x40) )   /* DQ6 == NO Toggle  */
             return FLASH_SUCCESS;
          /* Step 4: Else if DQ5 is zero then operation is not yet complete */
          if( (u2&0x20) == 0x00 )
             continue;
          /* Step 5: Else (DQ5 == 1), read DQ6 again */
          u1 = *pFA; //FlashRead( ANY_ADDR );    /* Read DQ6 from the Flash (any address) */
          u2 = *pFA; //FlashRead( ANY_ADDR );    /* Read DQ6 from the Flash (any address) */
          /* Step 6: If DQ6 did not toggle between the last two reads then
                     return FLASH_SUCCESS */
          if( (u2&0x40) == (u1&0x40) )   /* DQ6 == NO Toggle  */
             return FLASH_SUCCESS;
          /* Step 7: Else return FLASH_TOGGLE_FAIL */
          else {                              /* DQ6 == Toggle here means fail */
             return FLASH_TOGGLE_FAIL;
          }
       }  /* end of while loop */
    }


    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/31934/showart_331106.html
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP