|
wince6.0 nandflash 驱动 写入和读出内容不一样!!!!
[复制链接]
我的 nand 是K9F1G08 , 是128M的,BUFFERSIZE是 2048
每次我写2k 的数据,写完再读 发现只有前 512 的数据是一样,不知道是怎么回事!!
请教各位大虾!!!
unsigned int WritePage(U32 addr, U8 *buf)
{
unsigned int mecc;
unsigned char tmp[7];
unsigned char stat;
// Enable Chip
NFChipEn();
// Issue command
WrNFCmd(PROGCMD0);
// Setup address
WrNFAddr(0);
WrNFAddr(0);
WrNFAddr(addr);
WrNFAddr(addr >> 8);
// Initialize ECC register
InitEcc();
MEccUnlock();
for(unsigned int i=0; i
{
WrNFDat8(buf);
}
// Read out the ECC value generated by HW
MEccLock();
mecc = RdNFMEcc();
tmp[0] = mecc&0xff;
tmp[1] = (mecc>>8)&0xff;
tmp[2] = (mecc>>16)&0xff;
tmp[3] = (mecc>>24)&0xff;
tmp[5] = 0xff; //mark good block
WrNFDat8(0xff);//2048,坏块标志
SEccUnlock();
WrNFDat8(tmp[0]);//ECC校验码
WrNFDat8(tmp[1]);
WrNFDat8(tmp[2]);
WrNFDat8(tmp[3]);
SEccLock();
WrNFCmd(PROGCMD1);
stat = WaitNFBusy();
NFChipDs();
if(stat)
{
RETAILMSG(1,(TEXT("Write nand flash 0x%x fail\n"),addr));
}
else
{
#if 1
U8 RdDat[BUFFERSIZE];
ReadPage(addr, RdDat);
for(i=0; i
{
if(RdDat!=buf)//一旦大于512+16 这个位置就报错了
{
RETAILMSG(1,(TEXT("Check data at page 0x%x, offset 0x%x fail\n"),addr, i));
stat = 1;
break;
}
}
#endif
}
|
|