主题 : nand flash的读写问题,大家来看看! 复制链接 | 浏览器收藏 | 打印
级别: 侠客
UID: 709
精华: 1
发帖: 88
金钱: 595 两
威望: 131 点
综合积分: 196 分
注册时间: 2008-05-18
最后登录: 2018-02-08
楼主  发表于: 2008-06-27 21:25

 nand flash的读写问题,大家来看看!

假设我要从Nand Flash中的第5000字节处开始读取1024个字节到内存的0x30000000处,我们这样调用read函数nf_read(5000, 0x30000000,1024); 我们来分析5000这个src_addr。根据

column_addr=src_addr%512;       

page_address=(src_addr>>9);       

我们可得出

column_addr=5000%512=392

page_address=(5000>>9)=9

于是我们可以知道5000这个地址是在第9页的第392个字节处,于是我们的nf_read函数将这样发送命令和参数

column_addr=5000%512;

page_address=(5000>>9);

NF_CMD=0x01;                                          //从2nd half开始读取

NF_ADDR= column_addr &0xff;                // 1st Cycle

NF_ADDR=page_address&0xff;                  // 2nd.Cycle

NF_ADDR=(page_address>>8)&0xff;        // 3rd.Cycle

NF_ADDR=(page_address>>16)&0xff;      // 4th.Cycle




NF_ADDR= column_addr &0xff;这句的&0Xff是什么作用呀?保留低8位不变化,屏蔽其它位(也没有可屏蔽多的位了,呵呵)?  直按NF_ADDR= column_addr不行吗?
[ 此贴被maidilong在2008-06-27 21:31重新编辑 ]
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2008-06-30 07:19
这只是一种编程风格,在这个实例中,Columm地址只需要一个cycle,而且地址范围就在0~511,加不加&0xff都可以。但事实上,不要以为所有的NAND Flash的Columm地址都只需要一个cycle, 范围也都是在0~511。那只适用于Page Size/OOB size是512/16的NAND Flash.
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
2楼  发表于: 2008-06-30 07:26
想要知道如何处理不同的NAND Flash (512/2048 page size, 8/16bit ... ),最好的方法是先读它们自己的data sheet,弄清楚它们各自的编程方式和时序,然后再回来看NAND Flash controller的驱动为什么那么写
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."