s3c2440a裸奔4之NANDFLASH控制器2实验程序实现以下功能:1.开机蜂明器快响几声标志开机成功2.将NANDFLASH擦除3.分别将三个数组中的数据写入FLASH中4.等待按键识别(按键按下蜂名器发出响声)5.操作不同的按键MCU将从FLASH中不同的地址读取不同的数据,作为LED显示用数据注:主程序所引用的基础性库文件就不在这里列出(1)nandflash.h文件#include“2440addr.h”#definecmd_read10x00//页读命令周期1#definecmd_read20x30//页读命令周期2#definecmd_readid0x90//读NANDFLASHID命令#definecmd_reset0xff//命令NANDFLASH重起#definecmd_page_write10x80//页写命令周期1#definecmd_page_write20x10//页写命令周期2#definecmd_block_erase10x60//块擦除命令周期1#definecmd_block_erase20xd0//块擦除命令周期2#definecmd_readstatus0x70//读状态命令#definecmd_readrandom10x05//随意读命令周期1#definecmd_readrandom20xe0//随意读命令周期2#definecmd_writerandom0x85//随意写命令#defineNF_CMD(data){rNFCMD=(data);}//操作NANDFLASH的命令语句#defineNF_ADDR(addr){rNFADDR=(addr);}//传输地址#defineNF_RDDATA();(rNFDATA)//读32位数据#defineNF_RDDATA8();(rNFDATA8)//读8位数据#defineNF_WRDATA(data){rNFDATA=data;}//写32位数据#defineNF_WRDATA8(data){rNFDATA8=data;}//写8位数据//rNFCONT寄存器#defineNF_CE_L(){rNFCONT=rNFCONT&(~(11));}//打开nandflash片选#defineNF_CE_H(){rNFCONT=rNFCONT|(11);}//关闭nandflash片选#defineNF_RESETECC(){rNFCONT=rNFCONT|(14);}//ECC初始化s3c2440a裸奔4之NANDFLASH控制器2#defineNF_MECC_LOCK(){rNFCONT=rNFCONT|(15);}//锁定MAINECC#defineNF_MECC_UNLOCK(){rNFCONT=rNFCONT&(~(15));}//开锁MAINECC#defineNF_SECC_LOCK(){rNFCONT=rNFCONT|(16);}//锁定SPAREECC#defineNF_SECC_UNLOCK(){rNFCONT=rNFCONT&(~(16));}//开锁SPAREECC//rNFSTAT状态寄存器#defineNF_WAITRNB(){while((rNFSTAT&(10))==0);}//等待NANDFLASH空闲#defineNF_CLEAR_RB(){rNFSTAT|(12);}//不检测RNB传输#defineNF_DETECT_RB(){while(!(rNFSTAT&(12)));}//等待RnB信号变高,即不忙(2)USER程序文件:/************************************************************NANDFLASH实验****编制:徐斌*//************************************************************日期:2010年9月10日****功能描述:上电将数据保存到NANDFLASH中,通过按键识别判****断LED灯按照哪部分NANDFLASH数据进行显示************************************************************//*库文件调用程序************************************************************/#includedef.h#includeoption.h#include2440addr.h#include2440lib.h#include2440slib.h#includemath.h#includestdio.h#includestring.h#includenandflash.h/************************************************************内存定义程序************************************************************/#defineTACLS1#defineTWRPH02#defineTWRPH10#definekey_val0x000008e9unsignedintkey_temp=0xffffffff;unsignedcharbiaozhi_newkey=0;s3c2440a裸奔4之NANDFLASH控制器2unsignedintkey_new=0;unsignedintkey_old=0;unsignedcharflash_id=0;unsignedcharbiaozhi_startok=0;unsignedcharbiaozhi_work=0;unsignedcharbuf_temp[2048];unsignedinttemp;unsignedinttemp1;unsignedcharxu_temp;/************************************************************led显示数据************************************************************/constunsignedcharled_buf1[2048]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,s3c2440a裸奔4之NANDFLASH控制器20x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,