Associate
December 15, 2016
Question
Problem reading or writing to NAND Flash with FSMC
- December 15, 2016
- 4 replies
- 3004 views
Posted on December 15, 2016 at 18:13
Hello All,
I am working on STM32F407ZGT6 and HY27UF081G2A NAND Flash. You can find schematics and data sheets in the attached file. I am using CubeMX to generate codes on Keil U5. You can find initialization codes below.
/** Perform the NAND1 memory initialization sequence*/
hnand1.Instance = FSMC_NAND_DEVICE; /* hnand1.Init */ hnand1.Init.NandBank = FSMC_NAND_BANK2; hnand1.Init.Waitfeature = FSMC_NAND_PCC_WAIT_FEATURE_ENABLE; hnand1.Init.MemoryDataWidth = FSMC_NAND_PCC_MEM_BUS_WIDTH_8; hnand1.Init.EccComputation = FSMC_NAND_ECC_DISABLE; hnand1.Init.ECCPageSize = FSMC_NAND_ECC_PAGE_SIZE_512BYTE; hnand1.Init.TCLRSetupTime = 0x2; hnand1.Init.TARSetupTime = 0x2; /* hnand1.Info */ hnand1.Info.PageSize = 0x00000800; // 2048 Bytes/Page hnand1.Info.SpareAreaSize = 0x00000040; // 64 Bytes Spare hnand1.Info.BlockSize = 0x00000040; // 64 Pages/Block hnand1.Info.BlockNbr = 0x00000400; // 1024 Blocks hnand1.Info.ZoneSize = 0x00000400; // 1024 Blocks/Zone /* ComSpaceTiming */ ComSpaceTiming.SetupTime = 0x5; ComSpaceTiming.WaitSetupTime = 0x3; ComSpaceTiming.HoldSetupTime = 0x2; ComSpaceTiming.HiZSetupTime = 0x5; /* AttSpaceTiming */ AttSpaceTiming.SetupTime = 0x5; //0; AttSpaceTiming.WaitSetupTime = 0x3; //2; AttSpaceTiming.HoldSetupTime = 0x2; //1; AttSpaceTiming.HiZSetupTime = 0x5; //4;if (HAL_NAND_Init(&hnand1, &ComSpaceTiming, &AttSpaceTiming) != HAL_OK)
{ Error_Handler(); }When I try to readID (HAL_NAND_Read_ID) it looks like the CPU is stuck. It doesn't go further after the first line of the command sequence.
/* Send Read ID command sequence */
*(__IO uint8_t *)((uint32_t)(deviceaddress | CMD_AREA)) = NAND_CMD_READID;(it looks like it is in an infinite loop here)
*(__IO uint8_t *)((uint32_t)(deviceaddress | ADDR_AREA)) = 0x00U;I would appreciate it if someone help me with the issue.
Regards.
Tugrul
