STM32 读取 NAND512W3A2CN6E 的ID为20 76 20 76.但是读取不到status。一直为0x00.应该为0xC0才对的。这是怎么回事呢?有遇到这个情况的吗?
NAND_FLASH_Time.FSMC_SetupTime = 1; //建立时间
NAND_FLASH_Time.FSMC_HoldSetupTime = 3; //保持时间
NAND_FLASH_Time.FSMC_WaitSetupTime = 2; //等待时间
NAND_FLASH_Time.FSMC_HiZSetupTime = 1; //高阻建立时间
NAND_FLASHStru.FSMC_Bank = FSMC_Bank2_NAND; //使用FSMC BANK2
NAND_FLASHStru.FSMC_Waitfeature = FSMC_Waitfeature_Enable; //使能FSMC的等待功能
NAND_FLASHStru.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b; //NAND Flash 8bit
NAND_FLASHStru.FSMC_ECC = FSMC_ECC_Enable; //使能ECC特性
NAND_FLASHStru.FSMC_ECCPageSize = FSMC_ECCPageSize_512Bytes; //ECC页大小
NAND_FLASHStru.FSMC_TCLRSetupTime = 0;
NAND_FLASHStru.FSMC_TARSetupTime = 0;
NAND_FLASHStru.FSMC_AttributeSpaceTimingStruct = &NAND_FLASH_Time;
NAND_FLASHStru.FSMC_CommonSpaceTimingStruct = &NAND_FLASH_Time;
FSMC_NANDInit(&NAND_FLASHStru);
/*!使能FSMC BANK2 */
FSMC_NANDCmd(FSMC_Bank2_NAND, ENABLE);
u32 FSMC_NAND_ReadStatus(void)
{
u32 data = 0x00, status = NAND_BUSY;
/* Read status operation ------------------------------------ */
*(vu8 *)(Bank_NAND_ADDR | CMD_AREA) = NAND_CMD_STATUS;
data = *(vu8 *)(Bank_NAND_ADDR);
if((data & NAND_ERROR) == NAND_ERROR)//SR0
{
status = NAND_ERROR;
}
else if((data & NAND_READY) == NAND_READY)//SR6
{
status = NAND_READY;
}
else
{
status = NAND_BUSY;
}
return (status);
}
/* NAND Area definition Board RevD */
#define CMD_AREA (u32)(1<<16) /* A16 = CLE high */
#define ADDR_AREA (u32)(1<<17) /* A17 = ALE high */
#define DATA_AREA ((u32)0x00000000)
/* FSMC NAND memory command */
#define NAND_CMD_AREA_A ((u8)0x00) //area_a(Bytes0~255)
#define NAND_CMD_AREA_B ((u8)0x01) //area_b(Bytes256~511)
#define NAND_CMD_AREA_C ((u8)0x50) //area_c(Bytes512~527)
#define NAND_CMD_AREA_TRUE1 ((u8)0x30)
#define NAND_CMD_WRITE0 ((u8)0x80)
#define NAND_CMD_WRITE_TRUE1 ((u8)0x10)
#define NAND_CMD_ERASE0 ((u8)0x60)
#define NAND_CMD_ERASE1 ((u8)0xD0)
#define NAND_CMD_READID ((u8)0x90)
#define NAND_CMD_STATUS ((u8)0x70)
#define NAND_CMD_LOCK_STATUS ((u8)0x7A)
#define NAND_CMD_RESET ((u8)0xFF)
//60h Block_address D0h 70h->SR0
//SR6
/* NAND memory status */
#define NAND_VALID_ADDRESS ((u32)0x00000100)
#define NAND_INVALID_ADDRESS ((u32)0x00000200)
#define NAND_TIMEOUT_ERROR ((u32)0x00000400)
#define NAND_BUSY ((u32)0x00000000)
#define NAND_ERROR ((u32)0x00000001)
#define NAND_READY ((u32)0x00000040)
void FSMC_NAND_ReadID(NAND_IDTypeDef* NAND_ID)
{
u32 data = 0;
/*!< Send Command to the command area */
*(vu8 *)(Bank_NAND_ADDR | CMD_AREA) = 0x90;
*(vu8 *)(Bank_NAND_ADDR | ADDR_AREA) = 0x00;
/*!< Sequence to read ID from NAND flash */
data = *(vu32 *)(Bank_NAND_ADDR | DATA_AREA);
NAND_ID->Maker_ID = ADDR_1st_CYCLE (data);//四个周期读取四个ID
NAND_ID->Device_ID = ADDR_2nd_CYCLE (data);
NAND_ID->Third_ID = ADDR_3rd_CYCLE (data);
NAND_ID->Fourth_ID = ADDR_4th_CYCLE (data);
}
串口打印:SDRAM_16_write:eeff , SDRAM_16_read:eeff
NAND FLASH Status:0
Nand Flash ID = 20,76,20,76 |