📄 nand_test.c
字号:
#include "44b.h"
#include "nand.h"
#include "uart_lib.h"
#include "string.h"
void NandFlash_Test()
{
int i;
unsigned int m;
unsigned int BlockNo = 0;
char buffer[512];
char str[17]="0123456789abcdef";
char str2[17]="Smarteer12345678";
Uart_Printf("\n【NAND Flash测试程序:】\n");
for(i=0;i<32;i++)
strcpy(&buffer[i*16],str);
NandInit();
m = ReadDeviceID();
Uart_Printf("DeviceID = 0x%x\n",m);
m = EraseBlock(BlockNo);
if(m)
Uart_Printf("Erase Block %d Ok!\n",BlockNo);
else
Uart_Printf("Erase Block %d Failed!\n",BlockNo);
m = WritePage(0,1,buffer);
if(m)
Uart_Printf("Write page 1 %d bytes!\n",m);
else
Uart_Printf("Write page Failed!\n");
for(i=0;i<32;i++)
strcpy(&buffer[i*16],str2);
m = WritePage(0,2,buffer);
if(m)
Uart_Printf("Write page 2 %d bytes!\n",m);
else
Uart_Printf("Write page Failed!\n");
m = ReadPage(0,1,buffer);
Uart_Printf("Read page 1:\n");
for(m = 0; m < 512; m++)
Uart_SendByte(buffer[m]);
m = ReadPage(0,2,buffer);
Uart_Printf("Read page 2:\n");
for(m = 0; m < 512; m++)
Uart_SendByte(buffer[m]);
Uart_Printf("\n测试结束!\n");
}
// 总线极限速度 21秒钟100M
// IO极限速度 23秒钟100M
void NandFlash_Read(void)
{
unsigned int m;
char buffer[512] ;
int i;
NandInit();
m = ReadDeviceID();
Uart_Printf("DeviceID = 0x%x\n",m);
for(i=0;i<200;i++)
{
//rPDATC = 0x4200;
//rPDATC = 0x4000;
ReadPage(0,1,buffer);
}
for(m = 0; m < 512; m++)
Uart_SendByte(buffer[m]);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -