Nandflash的访问
Nandflash的访问
1.Nandflash的硬件连接:
2.K9F1G08U0C:
a.容量 : 256M(Byte)
b.页大小: (2K + 64) (Byte)
c.块大小: (128K + 4K)(Byte)
d.页数 : a / b =128K
e.对于256M的Nandflash, 需要28位的地址,发出命令后,后面紧跟着4个地址序列
f.对于k9f2g08u0c, 以页为单位进行读写, 以块为单位进行擦除.
3.命令字及其操作方法:
a.传输命令
b.传输地址
Column Address : 列地址
由于一页有 (2048 + 64)Byte , 所以需要 12 根地址线来寻址 , 即 A0 ~ A11.
Row Address : 行地址
由于整个Flash有128K个页 (Page), 所以需要 17 跟地址线来寻址 , 即A12 ~A28.
c.读/写数据 :
以页为单位进行读写, 以块为单位进行擦除.
4.操作K9F2G08U0C , 以读取Nand为例 , 没用ECC校验:
4.1. S3C2440 Nandflash 的 PIN Configuration
由于是2Kbyte的page , 5个cycle的地址 ,所以应该PIN Configuration 应该如下:
OM[1:0]: 00: - Enable NAND flash memory boot
NCON0 : 1 - Advance NAND flash(1KWords/2KBytes page size, 4/5 address cycle)
GPG13 : 1 - Page=512Bytes(NCON = 0) or Page=2KBytes(NCON = 1)
GPG14 : 1 - 4 address cycle(NCON = 0) or 5 address cycle(NCON = 1)
GPG15 : 0 - 0: 8-bit bus width
4.2. S3C2440 Nandflash Memory Timing:
4.2.1.K9F2G08U0C的Timing:
4.2.2. S3C2440的Timing
4.2.3. 使用默认的HCLK , 即 FCLK = HCLK = PCLK = 12Mhz .
4.2.4. 设置NFCONF (0x4E000000): 0x1000 .
TACLS [ 12 : 13 ] : 1 -Duration = HCLK x TACLS
TWRPH0 [ 8 : 10 ] : 0 -Duration = HCLK x ( TWRPH0 + 1 )
TWRPH1 [ 4 : 6 ] : 0 -Duration = HCLK x ( TWRPH1 + 1 )
BUSWIDTH [ 0 ] : 0 -8-bit bus
4.2.5. 设置NFCONT (0x4E000004): 0x12.
InitECC [4] : 1 -Initialize ECC decoder/encoder
Reg_nCE [1] :1 -Force nFCE to high (Disable chip select)
MODE [0] : 1 -NAND flash controller enable
4.2.6. 在第一次操作Nandflash前 , 复位Nandflash:
NFCONT &= ~(1 << 1) -Force nFCE to low (Enable chip select)
NFCMD = 0xff -reset
while( !(NFSTAT & 1) ) -Wait untill NAND Flash memory ready to operate
NFCONT |= (1 << 1) -Force nFCE to high (Disable chip select)
4.2.7. 发出读命令 :
NFCONT &= ~(1 << 1) -Force nFCE to low (Enable chip select)
NFCMD = 0 -Read command
4.2.8. 发出地址信号 :
NFADDR = addr 0xff -addr's bit[0:7] , 1st Cycle
NFADDR = (addr >> 8 ) & 0x0f -addr's bit[8:11] , 2nd Cycle
NFADDR = (addr >> 12)& 0xff -addr's bit[12:19], 3rd Cycle
NFADDR = (addr >> 20)& 0xff -addr's bit[20:27], 4th Cycle
NFADDR = (addr >> 28)& 0x01 -addr's bit[28], 5th Cycle
4.2.9.发送读确认命令
NFCMD = 0x30
4.2.10. 忙检测 :
while( !(NFSTAT & 1) ) -Wait untill NAND Flash memory ready to operate
4.2.11.读NFDATA寄存器2048次 ,得到一页数据 (2K Byte)
for(i =0; i<2048; i++) *p = NFDATA ;
4.2.12.取消选中芯片
NFCONT |= (1 << 1) -Force nFCE to high (Disable chip select)
本文永久更新链接地址:
评论暂时关闭