~Datasheet - Nand

看6410的datasheet:

打头的还是那句老话:“ Recently NOR flash memory price has increased and price for SDRAM and a NAND flash memory is moderatly placed. “

瞧一瞧有哪些特点,哪些是需要注意的

NAND flash controller features include:



1. NAND Flash memory I/F: Support 512Bytes and 2KBPage .



2. Software mode: User can directly access NAND flash memory. for example this feature can be used in read/erase/program NAND flash memory.



3. Interface: 8-bit NAND flash memory interface bus.



4. Hardware ECC generation, detection and indication (Software correction).



5. Support both SLC and MLC NAND flash memory : 1-bit ECC, 4-bit and 8-bit ECC for NAND flash. (Recommend: 1bit ECC for SLC, 4bit and 8bit ECC for MLC NAND Flash)



补充:这里要注意一下,一般是4bit,但好的nand,比如Micron用1bit也可以。



6. SFR I/F: Support Byte/half word/word access to Data and ECC Data register, and Word access to other registers



7. SteppingStone I/F: Support Byte/half word/word access.



8. TheSteppingstone 8-KBinternal   

 

              

  • 设置片选:

~Datasheet - Nand

xm0csn2用作nand flash cs0 片选引脚。

 ~Datasheet - Nand

 

  • 需要配置寄存器:03-SystemController

~Datasheet - Nand

将第[1]位设为0.

nand涉及的寄存器虽然很多,但重要的也就几个,而ECC的配置大多是默认或者只读。

配置寄存器NFCONF,主要配置以下几个引脚的延时,具体查看nand datasheet:

~Datasheet - Nand
 

 

  • 寄存器配置:
  NFCONF &= ~((1<<30) | (7<<12) | (7<<8) | (7<<4));



  NFCONF |= ((TACLS<<12) | (TWRPH0<<8) | (TWRPH1<<4));



然后使能:



  NFCONT |= 1;



配置好后,首先要reset下:



  void nand_reset(void)

  {

    nand_select();           /* 选中 */

     



    nand_cmd(0xff);       /* 发出0xff命令 */

    ~Datasheet - Nand



    wait_ready();           /* 等待nand状态就绪 NFSTAT */

    nand_deselect();        /* 取消选中 */



  }

 

之后便可以操作nand读写。比如,将nand的内容读取到内存上。

int copy2ddr(unsigned int nand_start, unsigned int ddr_start, unsigned int len)

{

    int ret;



    /* 初始化 */

    nand_init();



    /* 读nand flash */

    ret = nand_read(nand_start, ddr_start, len);    //-->



    return ret;

}

   

读取的过程要看nand datasheet时序:

/* 选中芯片 */

nand_select(); //NFCONT



while (count < len)

{

    /* 发出命令0x00 */

    nand_cmd(0x00); //NFCMMD



    /* 发出地址 */

    nand_send_addr(addr); // NFADDR

    

    /* 发出命令0x30 */

    nand_cmd(0x30);  //NFCMMD



    /* 等待就绪 */

    while(!(NFSTAT & 0x1 )) //NFSTAT

        ;



    /* 读数据 */

    for (i = 0; i < 2048 && count < len; i++)

    {

        dest[count++] = nand_get_data(); // 读取NFDATA

    }



    addr += 2048; //读取单位:页大小2048

}



/* 取消片选 */

nand_deselect(); //NFCONT

 

关于nand读写命令,参见 nand datasheet的命令表:

 ~Datasheet - Nand

 

 

http://hi.baidu.com/kebey2004/item/a70f077bf3921f366f29f6ff

你可能感兴趣的:(Data)