?? 2440nand.c
字號:
#include "2440addr.h"
#include "2440lib.h"
#include "def.h"
#include "nand.h"
#define NFBlcokAddr 0x3ffc000
void xmain(void)
{
U16 ID,i;
U8 buf[512];
U32 NFBlockNO;
U32 NFPagesNO = 31;
U32 status;
NFBlockNO = (NFBlcokAddr>>14);
ChangeClockDivider(3,1);
ChangeMPllValue(127,2,1); //405MHZ
Isr_Init();
Uart_Init(0, 115200);
Uart_Select(0);
Uart_Printf("\nthe main is running\n");
NF8_Init();
ID=NF8_CheckId();//ID=EC76
Uart_Printf("\nnand flash`s ID is:%x\n",ID);
status = NF8_IsBadBlock(NFBlockNO);
if(status == TRUE) Uart_Printf("\nblock good OK.\n");
else Uart_Printf("\nblock bad.\n");
if(NF8_EraseBlock(NFBlockNO))
{
Uart_Printf("\nblock %d is erased\n",NFBlockNO);
for(i=0; i<512; i++)
{
buf[i] = i;
Uart_Printf("%4x", buf[i]);
}
Uart_Printf("\nWrite data[%d block, %d page].\n", NFBlockNO,NFPagesNO);
status = NF8_WritePage(NFBlockNO,NFPagesNO,buf);
if(status == TRUE) Uart_Printf("\nWrite OK.\n");
else Uart_Printf("\nWrite Error.\n");
for(i=0; i<512; i++)
buf[i] = 0;
NF8_ReadPage(NFBlockNO,NFPagesNO,buf);
Uart_Printf("\nRead data[%d block, %d page].\n", NFBlockNO,NFPagesNO);
for(i=0; i<512; i++)
Uart_Printf("%4x", buf[i]);
while(1);
}
Uart_Printf("\nblock %4x erased is bad\n",NFBlockNO);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -