最近在做NAND FLASH加FATFS文件系统 要求只读NAND FLASH中的文件即可 下面是 NANDFLASH的读函数, 不加系统的时候可以读写 正常 。加了文件系统之后 就是读不到数据呀 报的FR_NO_FILE, /* (4) Could not find the file */错误 求大神帮忙分析一下
uint32 FlashReadOneSector(uint32 Addr, uint8 * pBuf, uint32 Remain)
{
uint32 i;
while(Remain--)
{
FlashClrCe();
if(Addr>FLASH_MAX_SECTOR_ADDR) return 1;
Addr=FlashAddrRemap(Addr);
if((Addr&(~(FLASH_PAGE_SIZE-1))) != (FlashCurrentReadSectorAddr&(~(FLASH_PAGE_SIZE-1))))
{
FlashWriteCommand(0x00);
FlashWriteAddr4Byte(Addr);
FlashWriteCommand(0x30);
FlashWait(); //µÈ´ýÊý¾Ý¶Á»Ø
}
else
{
FlashWriteCommand(0x05);
FlashWriteAddr2Byte(Addr);
FlashWriteCommand(0xE0);
FlashWait();
}
for(i=0;i<FLASH_SECTOR_SIZE + FLASH_SECTOR_SIZE * Remain;i++)
{
pBuf[i]=FlashReadByte();
}
FlashCurrentReadSectorAddr=Addr;
if(Remain==0)
{
FlashCurrentReadSectorAddr=-1;
}
FlashSetCe(); //ÊÍ·Å×ÜÏß
}
return 0;
}
关键词:
STM32
NAND FLASH
FATFS