• 开心果大汉
    了解作者
  • C/C++
    开发工具
  • 1KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 10 积分
    下载积分
  • 4615
    下载次数
  • 2005-09-11 03:54
    上传日期
Nand flash 读写程序 C语言代码,可以给U盘开发者参考 可以读写三星各种型号的Nand flash芯片
NAND FLASH的读写程序.rar
  • www.pudn.com.txt
    218B
  • NAND FLASH的读写程序.txt
    2.6KB
内容介绍
NAND FLASH的读写程序(注意片选) 【浩惠电子 http://www.hheet.com/bbs 版权所有】 FLASH是K9F5608U0B,32M #include<INIT_REG.H> #define FLASH_MD1 0xeff0 //chip enable nand flash 1 #define FLASH_MD2 0xfff0 //chip enable nand flash 2 #define FLASH_MA1 0xeff2 //enable address nand flash 1 #define FLASH_MA2 0xfff2 //enable address flash 2 #define FLASH_MC1 0xeff1 //enable command nand flash 1 #define FLASH_MC2 0xfff1 //enable command nand flash 2 #define read_id 0x90 void read_flash_id(void); void page_write_flash(unsigned char addrlow,addrmid,addrhigh); void read_flash(unsigned char addrlow,addrmid,addrhigh); void delay(); void flash_reset(); void main(void) { unsigned char i=0,j=0; init_snd1(); flash_reset(); read_flash_id(); page_write_flash(0x0,0x0,0x0); read_flash(0x0,0x0,0x0); while(1); } void flash_reset() { unsigned char xdata *xaddress; xaddress=FLASH_MC1; *xaddress=0xff; delay(); } void read_flash_id(void) // 串口输出ID码 { unsigned char xdata *xaddress; unsigned char x,y; xaddress=FLASH_MC1; *xaddress=read_id; xaddress=FLASH_MA1; *xaddress=0x00; xaddress=FLASH_MD1; x=*xaddress; printf(x); y=*xaddress; printf(y); } void page_write_flash(unsigned char addrlow,addrmid,addrhigh) { unsigned char xdata *buff; unsigned char temp; unsigned int i; //erase flash block buff=FLASH_MC1; *buff=0x60; buff=FLASH_MA1; *buff=addrmid; *buff=addrhigh; buff=FLASH_MC1; *buff=0xd0; delay(); do{ buff=FLASH_MC1; *buff=0x70; buff=FLASH_MD1; temp=*buff; printf(temp); temp=temp&0x01; } while(temp!=0x00); //while(1); //erase sucessfull //write one page data buff=FLASH_MC1; *buff=0x80; buff=FLASH_MA1; *buff=addrlow; *buff=addrmid; *buff=addrhigh; buff=FLASH_MD1; for(i=0;i<512;i++) { *buff=i; printf(i); } buff=FLASH_MC1; *buff=0x10; delay(); do{ buff=FLASH_MC1; *buff=0x70; buff=FLASH_MD1; temp=*buff; printf(temp); temp=temp&0x41; } while(temp!=0x40); } void read_flash(unsigned char addrlow,addrmid,addrhigh) { unsigned char xdata *source; unsigned int i,temp; source=FLASH_MC1; *source=0x00; source=FLASH_MA1; *source=addrlow; *source=addrmid; *source=addrhigh; delay(); do{ source=FLASH_MC1; *source=0x70; source=FLASH_MD1; temp=*source; printf(temp); temp=temp&0x40; } while(temp!=0x40); source=FLASH_MD1; i=512; while((i--)>0) { temp=*source; printf(temp); } } void delay() { unsigned int temp; for (temp=0; temp<3000;temp++) ; }
评论
  • PUDN用户 2009-08-19 03:52:00
    希望能给出更详细的资料
  • PUDN用户 2009-07-10 19:49:58
    资料不全
  • PUDN用户 2009-01-16 18:01:54
    不实用,读写还行,连ECC都没
  • PUDN用户 2006-05-20 19:45:39
    不错,可供参考
相关推荐