main.c
来自「nand flash读写实验代码」· C语言 代码 · 共 44 行
C
44 行
#include "2410addr.h"
#include "2410lib.h"
#include "def.h"
#include "nandflash.h"
void Main(void)
{
U32 i;
U8 buf[512];
U32 ID;
ChangeClockDivider(1,1);
ChangeMPllValue(0xa1,0x3,0x1);
Port_Init();
Uart_Select(0);
Uart_Init(0,115200);
Uart_Printf("Nand flash test \n");
InitNandCfg();
ID=ReadChipId();//ID=EC76
Uart_Printf("nand flash`s ID is:%x\n",ID);
if(EraseBlock(NFBlcokAddr))
{
Uart_Printf("block %4x is erased\n",NFBlcokAddr);
for(i=0; i<256; i++)
{
buf[i] = i;
Uart_Printf("%4x", buf[i]);
}
WritePage(NFBlcokAddr, buf);
for(i=0; i<256; i++)
buf[i] = 0;
ReadPage(NFBlcokAddr, buf);
for(i=0; i<256; i++)
Uart_Printf("%4x", buf[i]);
while(1);
}
Uart_Printf("block %4x erased is bad\n",NFBlcokAddr);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?