我根据flash数据手册 用下面这种方法发地址,为什么无**常读取呢?页面的大小是2K。
static void s3c2440_write_addr(unsigned int addr)
{
volatile unsigned char *p = (volatile unsigned char *)&s3c2440nand->NFADDR;
//这是我改后 无**常读取的程序
*p = addr & 0xff; /* Column Address A0~A7 */
for(i=0; i<10; i++);
*p = (addr >> 8) & 0x0f; /* Column Address A8~A11 */
for(i=0; i<10; i++);
*p = (addr >> 12) & 0xff; /* Row Address A12~A19 */
for(i=0; i<10; i++);
*p = (addr >> 20) & 0xff; /* Row Address A20~A27 */
for(i=0; i<10; i++);
//改成下面程序的程序可以
int col, page;
col = addr & NAND_BLOCK_MASK; /*NAND_BLOCK_MASK=NAND_SECTOR_SIZE-1*/
page = addr / NAND_SECTOR_SIZE;/*NAND_SECTOR_SIZE=2048*/
*p = col & 0xff; /* Column Address A0~A7 */
for(i=0; i<10; i++);
*p = (col >> 8) & 0x0f; /* Column Address A8~A11 */
for(i=0; i<10; i++);
*p = page & 0xff; /* Row Address A12~A19 */
for(i=0; i<10; i++);
*p = (page >> 8) & 0xff; /* Row Address A20~A27 */
for(i=0; i<10; i++);
}
把程序修改成如下则能正常运行。
*p = addr & 0xff; /* Column Address A0~A7 */
for(i=0; i<10; i++);
*p = (addr >> 8) & 0x0f; /* Column Address A8~A11 */
for(i=0; i<10; i++);
*p = (addr >> 11) & 0xff; /* Row Address A12~A19 */ 为什是11,而不是12????
for(i=0; i<10; i++);
*p = (addr >> 19) & 0xff; /* Row Address A20~A27 */为什是19,而不是20????
for(i=0; i<10; i++);
下面的表格是nandflash 数据手册中的地址分配,前面两个周期是Column Address,后面的是Row Address
| I/O 0 | I/O 1 | I/O 2 | I/O 3 | I/O 4 | I/O 5 | I/O 6 | I/O 7 | 1st Cycle
| A0 | A1 | A2 | A3 | A4 | A5 | A6 | A7 | 2nd Cycle | A8 | A9 | A10 | A11 | *L | *L | *L | *L | 3rd Cycle | A12 | A13 | A14 | A15 | A16 | A17 | A18 | A19 | 4th Cycle | A20 | A21 | A22 | A23 | A24 | A25 | A26 | A27 |
|