打印

STM32F407读写NAND FLASH ReadSmallPage 只能读一页

[复制链接]
318|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
第8号打板工|  楼主 | 2018-7-29 16:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
为何 NumPageToRead=1时可以正常读数据,而=2时没有读到任何数据?

读操作程序如下:
uint32_t FSMC_NAND_ReadSmallPage(uint16_t *pBuffer, NAND_ADDRESS Address, uint32_t NumPageToRead)
{
  uint32_t index = 0x00, numpageread = 0x00, addressstatus = NAND_VALID_ADDRESS;
  uint32_t status = NAND_READY, size = 0x00;

  while((NumPageToRead != 0x0) && (addressstatus == NAND_VALID_ADDRESS))
  {           
    /* Page Read command and page address */
    *(vu8 *)(NAND_FLASH_START_ADDR | CMD_AREA) = NAND_CMD_READ_1;

    *(vu8 *)(NAND_FLASH_START_ADDR | ADDR_AREA) = 0x00;
    *(vu8 *)(NAND_FLASH_START_ADDR | ADDR_AREA) = 0X00;
    *(vu8 *)(NAND_FLASH_START_ADDR | ADDR_AREA) = ADDR_1st_CYCLE(ROW_ADDRESS);  
    *(vu8 *)(NAND_FLASH_START_ADDR | ADDR_AREA) = ADDR_2nd_CYCLE(ROW_ADDRESS);  

    *(vu8 *)(NAND_FLASH_START_ADDR | CMD_AREA) = NAND_CMD_READ_TRUE;


   while( GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_6) == 0 );

    /* Calculate the size */
    size = NAND_PAGE_SIZE + (NAND_PAGE_SIZE * numpageread);

        for(index=0; index < 0x490; index++){}/延时

    /* Get Data into Buffer */   
    for(; index < size; index++)
    {
      pBuffer[index]= *(vu16 *)(NAND_FLASH_START_ADDR | DATA_AREA);
    }

    numpageread++;

    NumPageToRead--;

    /* Calculate page address */                                    
    addressstatus = FSMC_NAND_AddressIncrement(&Address);
  }

  status = FSMC_NAND_GetStatus();

  return (status | addressstatus);
}

test程序:
void FSMC_NAND_Test(void)
{
  uint16_t index;
    uint16_t j;
  NAND_IDTypeDef NAND_ID;
  NAND_ADDRESS WriteReadAddr;

  FSMC_NANDDeInit(FSMC_Bank2_NAND);
  FSMC_NAND_Init();


  FSMC_NAND_ReadID(&NAND_ID);
  printf("Nand Flash ID = %02X,%02X,%02X,%02X  ",NAND_ID.Maker_ID, NAND_ID.Device_ID,
                                                         NAND_ID.Third_ID, NAND_ID.Fourth_ID );
  if ((NAND_ID.Maker_ID == 0xEC) && (NAND_ID.Device_ID == 0xF1)
                && (NAND_ID.Third_ID == 0x80) && (NAND_ID.Fourth_ID == 0x15))
  {
         printf("Type = K9F1G08U0A
");
  }
  else if ((NAND_ID.Maker_ID == 0xEC) && (NAND_ID.Device_ID == 0xF1)
                && (NAND_ID.Third_ID == 0x00) && (NAND_ID.Fourth_ID == 0x95))
  {
         printf("Type = K9F1G08U0B
");               
  }
  else if ((NAND_ID.Maker_ID == 0xAD) && (NAND_ID.Device_ID == 0xF1)
                && (NAND_ID.Third_ID == 0x80) && (NAND_ID.Fourth_ID == 0x1D))
  {
         printf("Type = HY27UF081G2A
");               
  }
  else
  {
         printf("Type = Unknow
");
  }

  /* NAND memory address to write to */
  WriteReadAddr.Zone = 0x00;
  WriteReadAddr.Block = 0x00;
  WriteReadAddr.Page = 0x00;


  /* Erase the NAND first Block */
  FSMC_NAND_EraseBlock(WriteReadAddr);

  /* Write data to FSMC NOR memory */
  /* Fill the buffer to send */
  for (index = 0; index < 3000; index++ )
  {
     TxBuffer[index] = index;
  }

  FSMC_NAND_WriteSmallPage(TxBuffer, WriteReadAddr, 2);
   printf("
Written to the number of£o
");
   for(j = 0; j < 3000; j++)
        printf("%x  
",TxBuffer[j]);

  /* Read back the written data */
  FSMC_NAND_ReadSmallPage (RxBuffer, WriteReadAddr, 2);
     printf("
Read several£o
");
    for(j = 0; j < 3000; j++)
        printf("%x  
",RxBuffer[j]);   


}

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

393

主题

393

帖子

0

粉丝