cancel
Showing results for 
Search instead for 
Did you mean: 

Problem reading or writing to NAND Flash with FSMC

Tugrul Matras
Associate
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

6 REPLIES 6
Tugrul Matras
Associate
Posted on December 15, 2016 at 18:37

hnand1.Init.Waitfeature = FSMC_NAND_PCC_WAIT_FEATURE_ENABLE;

to 

hnand1.Init.Waitfeature = FSMC_NAND_PCC_WAIT_FEATURE_DISABLE;

solved the problem

Posted on April 14, 2017 at 06:19

Thank you very very much!! You have just save my week!!

Posted on June 19, 2017 at 16:29

Thank you!

I had the same Problem.

@ST: is there an option in CubeMX to configure the 

Waitfeature ? If not, can you add it?

Thanks a lot!

Imen.D
ST Employee
Posted on June 29, 2017 at 14:24

Hello,

Your request raised internally to the appropriate team.

Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Abdul Qadir Shabbir
Associate II
Posted on October 30, 2017 at 23:03

Hi Tugrul Matras, 

I am new to ST and am using the same config to read the Nand flash. Did your profiled on how quickly you can read from the flash. I see that the reads using processor are extremely slow. 

Thanks, 

AQ

Jeanne Joly
Senior III
Posted on January 30, 2018 at 09:13

Hi

Matras.Tugrul

,

Granados.Elkin

and

Tekampe.Jens

,

Regarding

Matras.Tugrul

'spost, you can change the value of

hnand1.Init.Waitfeature in the pinout view/FSMC/Nand Flash1/ Ready or busy (I am working on the lastest CubeMX release 4.24) :

0690X00000609PMQAY.png

it will automatically generate the following code :

0690X00000609XcQAI.png

BR. Jeanne