void NAND_Init()
{
*(unsigned int *)(0x20030000 + 0xd0) = 7; delay_x(0X5000);
*(unsigned int *)(0x20030000 + 0xd0) = 6; delay_x(0X5000);
*(unsigned int *)(0x200f0000 + 0x1fc) = 0;//muxctrl_reg127 NF_DQ0 管脚复用控制寄存器
*(unsigned int *)(0x200f0000 + 0x200) = 0;
*(unsigned int *)(0x200f0000 + 0x204) = 0;
*(unsigned int *)(0x200f0000 + 0x208) = 0;
*(unsigned int *)(0x200f0000 + 0x20C) = 0;
*(unsigned int *)(0x200f0000 + 0x210) = 0;
*(unsigned int *)(0x200f0000 + 0x214) = 0;
*(unsigned int *)(0x200f0000 + 0x218) = 0;//7
*(unsigned int *)(0x200f0000 + 0x21C) = 0;
*(unsigned int *)(0x200f0000 + 0x220) = 0;
//p626
*(unsigned int *)(NANDC_ADDR +0X00) = 0x85;//NFC_CON
*(unsigned int *)(NANDC_ADDR +0X04) = 0x666;//NFC_PWIDTH 为读写脉冲宽度配置寄存器。
*(unsigned int *)(NANDC_ADDR +0X24) = 0x0;//NFC_INTEN 为中断使能寄存器
delay_x(0X500);
}
void NAND_Read_Page()
{
*(unsigned int *)(NANDC_ADDR +0X10) = 0x0;//NFC_ADDRL 为低位地址配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X14) = 0x0;//NFC_ADDRH 为高位地址配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X0c) = 0x00003000;//NFC_CMD 为命令字配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X18) = 0x800;
delay_x(0X500);
//地址周期 cmd1_en addr_wen data_wen cmd2_en ready/busy data_ren read_stus_en
*(unsigned int *)(NANDC_ADDR +0X1c) = 5<<9 | 1<<6 | 1<<5 | 0<<4 | 1<<3 |1<<2 | 1<<1 | 0;//0xa6e;//NFC_OP 为操作寄存器。
delay_x(0X500);
retu = *(unsigned int *)(NANDC_ADDR +0X20) ;//NFC_STATUS 为状态寄存器。
delay_x(0X5000);
}
void NAND_Read_Random()
{
*(unsigned int *)(NANDC_ADDR +0X10) = 0x0;//NFC_ADDRL 为低位地址配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X14) = 0x0;//NFC_ADDRH 为高位地址配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X0c) = 0x0000e005;//NFC_CMD 为命令字配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X18) = 0x20;
delay_x(0X500);
//*(unsigned int *)(NANDC_ADDR +0X1c) = 0x46e;//NFC_OP 为操作寄存器。
//地址周期 cmd1_en addr_wen data_wen cmd2_en ready/busy data_ren read_stus_en
*(unsigned int *)(NANDC_ADDR +0X1c) = 2<<9 | 1<<6 | 1<<5 | 0<<4 | 1<<3 |1<<2 | 1<<1 | 0;////NFC_OP 为操作寄存器。
delay_x(0X500);
retu = *(unsigned int *)(NANDC_ADDR +0X20) ;//NFC_STATUS 为状态寄存器。
delay_x(0X5000);
}
void NAND_Write_Page()
{
*(unsigned int *)(NANDC_ADDR +0X10) = 0x0;//NFC_ADDRL 为低位地址配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X14) = 0x0;//NFC_ADDRH 为高位地址配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X0c) = 0x00001080;//NFC_CMD 为命令字配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X18) = 8;
delay_x(0X500);
*(unsigned int *)(0x50000000) = 0x11223344;
delay_x(0X500);
*(unsigned int *)(0x50000004) = 0x55667788;
delay_x(0X500);
// *(unsigned int *)(NANDC_ADDR +0X1c) = 0xa7d;//NFC_OP 为操作寄存器。
//地址周期 cmd1_en addr_wen data_wen cmd2_en ready/busy data_ren read_stus_en
*(unsigned int *)(NANDC_ADDR +0X1c) = 5<<9 | 1<<6 | 1<<5 | 1<<4 | 1<<3 |1<<2 | 0<<1 | 0;//NFC_OP 为操作寄存器。
delay_x(0X500);
retu = *(unsigned int *)(NANDC_ADDR +0X20) ;//NFC_STATUS 为状态寄存器。
delay_x(0X5000);
}
void NAND_ReadID()
{
*(unsigned int *)(NANDC_ADDR +0X10) = 0x20;//NFC_ADDRL 为低位地址配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X14) = 0x0;//NFC_ADDRH 为高位地址配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X0c) = 0x00000090;//NFC_CMD 为命令字配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X18) = 5;
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X1c) = 0x266;//NFC_OP 为操作寄存器。
delay_x(0X500);
retu = *(unsigned int *)(NANDC_ADDR +0X20) ;//NFC_STATUS 为状态寄存器。
delay_x(0X5000);
}
void NAND_Erase_Block()
{
*(unsigned int *)(NANDC_ADDR +0X10) = 0x0;//NFC_ADDRL 为低位地址配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X14) = 0x0;//NFC_ADDRH 为高位地址配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X0c) = 0x0070d060;//NFC_CMD 为命令字配置寄存器。
delay_x(0X500);
//*(unsigned int *)(NANDC_ADDR +0X1c) = 0x66c;//NFC_OP 为操作寄存器。
//地址周期 cmd1_en addr_wen data_wen cmd2_en ready/busy data_ren read_stus_en
*(unsigned int *)(NANDC_ADDR +0X1c) = 3<<9 | 1<<6 | 1<<5 | 0<<4 | 1<<3 |1<<2 | 0<<1 | 0;//0xa6e;//NFC_OP 为操作寄存器。
delay_x(0X500);
retu = *(unsigned int *)(NANDC_ADDR +0X20) ;//NFC_STATUS 为状态寄存器。
delay_x(0X5000);
}
int NAND_test(unsigned int data)
{
int i=0;
UART_Init();
NAND_Erase_Block();
//写数据
*(unsigned int *)(NANDC_ADDR +0X10) = 0x0;//NFC_ADDRL 为低位地址配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X14) = 0x0;//NFC_ADDRH 为高位地址配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X0c) = 0x00001080;//NFC_CMD 为命令字配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X18) = 0x800;
delay_x(0X500);
for(i=0;i<(0x800/4);i++)
{
*(unsigned int *)(0x50000000 + i*4) = data;
delay_x(0X500);
}
// *(unsigned int *)(NANDC_ADDR +0X1c) = 0xa7d;//NFC_OP 为操作寄存器。
//地址周期 cmd1_en addr_wen data_wen cmd2_en ready/busy data_ren read_stus_en
*(unsigned int *)(NANDC_ADDR +0X1c) = 5<<9 | 1<<6 | 1<<5 | 1<<4 | 1<<3 |1<<2 | 0<<1 | 0;//NFC_OP 为操作寄存器。
delay_x(0X500);
retu = *(unsigned int *)(NANDC_ADDR +0X20) ;//NFC_STATUS 为状态寄存器。
//读数据
NAND_Read_Page();
//随即读
*(unsigned int *)(NANDC_ADDR +0X10) = 0x0;//NFC_ADDRL 为低位地址配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X14) = 0x0;//NFC_ADDRH 为高位地址配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X0c) = 0x0000e005;//NFC_CMD 为命令字配置寄存器。
delay_x(0X500);
*(unsigned int *)(NANDC_ADDR +0X18) = 0x800;
delay_x(0X500);
//*(unsigned int *)(NANDC_ADDR +0X1c) = 0x46e;//NFC_OP 为操作寄存器。
//地址周期 cmd1_en addr_wen data_wen cmd2_en ready/busy data_ren read_stus_en
*(unsigned int *)(NANDC_ADDR +0X1c) = 2<<9 | 1<<6 | 1<<5 | 0<<4 | 1<<3 |1<<2 | 1<<1 | 0;////NFC_OP 为操作寄存器。
delay_x(0X500);
retu = *(unsigned int *)(NANDC_ADDR +0X20) ;//NFC_STATUS 为状态寄存器。
//判断数据是否正确。
for(i=0;i<(0x800/4);i++)
{
retu = *(unsigned int *)(0x50000000 + i*4);
if(retu != data)
return 1;
delay_x(0X500);
}
return 0;
}
上一篇:ADS1.2中RO base与RW base
下一篇:修正uboot网络不可用
设计资源 培训 开发板 精华推荐
- 【已结束】TI 有奖直播|CAN SIC(信号改进功能)
- Molex紧凑型Type-C连接器 为您的设计节约宝贵空间!下载好礼送!
- 你有原创我有奖,等值现金奖励最高到500
- 是德科技 DATA Center 资料,满足您的需求~下载有好礼!
- 从终端到架构,TE Connectivity(TE)助你连接5G高速未来 看视频答题赢好礼!
- 【把你我的经验串一串,共享丰收】EEWORLD优秀主题/回复第17期活动开始拉
- TE白皮书下载|《散热桥技术——电子设备散热领域的创新》
- 是德科技有奖直播:元宇宙测试系列研讨会之VR/AR 数字接口测试的挑战
- 是德科技有奖直播:如何让你的Wi-Fi测试“兔”飞猛进?
- 【抢楼有礼】聊聊我们遇到的电感问题!