Nand driver
1. 以下是以Samsung某款Nand为例
1 Page = (2K + 64)Bytes
1 Block = (2K + 64)B x 64 Pages = (128K + 4K) Bytes
1 Device = (2K+64)B x 64Pages x 4,096 Blocks= 4,224 Mbits =512MB
以前的SmallPage的通常
1Page = (512 + 16)Bytes
1Block = (512 + 16) * 64Pages = 32K + 1K
地址通常先两个Column地址(A0-A11), 后三个Row地址(A12-A29)
Write&Read是以Page为单位的, Erase是以Block为单位的, 通常Write之前要Erase
2. Pin定义
I/O0-I/O7 数据
CLE Command Latch Enable
ALE Address Latch Enable
CE Chip Enable(Low activated)
RE Read Enable (Low activated)
WE Read Enable(Low activated)
WP Write Protected(Low actived)
R/B Ready/Busy
VCC Power
VSS Ground
3. 命令集
4.基本函数
通常会有三个地址:
读数据的地址READ_DATA
写地址的地址WRITE_ADDR
写数据/命令的地址WRITE_COM
4.1 ID detection
WriteCommand(0x90); //output to WRITE_COM
WriteAddr(0x0); //output to WRITE_ADDR
ManufacturerID=ReadOneByte(); //0xEC Samsung, 0x20 ST
DeviceID=ReadOneByte();
4.2 Reset
WriteCommand(0xFF)
4.3 ReadOnePage
WriteCommand(0x00);
WriteAddr(Column地址的低8位, A0-A7);
WriteAddr(Column地址的高4位, A8-A11);
WriteAddr(Row地址的低8位, A12-A19);
WriteAddr(Row地址的中间8位, A20-A27);
WriteAddr(Row地址的高2位, A28-A29);
WriteCommand(0x30);
Reset HW ECC, Read 512Bytes, Get HW ECC (loop 4 times)
Read Spare data
Compare ECC, Correct ECC if needed
4.4. WriteOnePage
WriteCommand(0x80);
WriteAddr(Column地址的低8位, A0-A7);
WriteAddr(Column地址的高4位, A8-A11);
WriteAddr(Row地址的低8位, A12-A19);
WriteAddr(Row地址的中间8位, A20-A27);
WriteAddr(Row地址的高2位, A28-A29);
Reset HW ECC, Write 512 Bytes, Get HW ECC (loop 4 times)
Write ECC data to spare area
WriteCommand(0x30);
4.5 EraseOneBlock
WriteCommand(0x60);
WriteAddr(Row地址的低8位, A12-A19);
WriteAddr(Row地址的中间8位, A20-A27);
WriteAddr(Row地址的高2位, A28-A29);
WriteCommand(0xD0);