cancel
Showing results for 
Search instead for 
Did you mean: 

During nand flash erase, uart interrupt doesn't work properly.

togsin
Associate II

Dear all

During nand flash erase, uart interrupt doesn't work properly. (same SysTick_Handler)

Let me know why this is happening.

nand flash erase source :

for(Addr.Plane=0;Addr.Plane<2;Addr.Plane++)

{

for(Addr.Block=0;Addr.Block<2048;Addr.Block++)

{

HAL_NAND_Erase_Block(&hnand1, &Addr);

}

}

Thanks

3 REPLIES 3
berendi
Principal

The exact cause might depend on the flash chip model and the FMC configuration, so the following is just my speculation.

I think that the flash chip holds the NWAIT line low during the erase operation, blocking the external memory bus, which would in turn block the internal bus as soon as HAL_NAND_Erase_Block() starts polling the status register of the flash. When the internal bus is blocked, the MCU can't fetch more instructions, so interrupt handlers cannot be executed.

I would reimplement the erase function without HAL, and check the NWAIT line before trying to read the status register from flash. Even if the NWAIt pin is configured in alternate function mode, reading the pin state through GPIOx->IDR should work. Look up the signal interface in the flash datasheet, and check the pins to see when it's safe to issue the read status command.

togsin
Associate II

This is nand flash configration :

Can you check config?

 /** Perform the NAND1 memory initialization sequence

 */

 hnand1.Instance = FSMC_NAND_DEVICE;

 /* hnand1.Init */

 hnand1.Init.NandBank = FSMC_NAND_BANK3;

 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_ENABLE;

 hnand1.Init.ECCPageSize = FSMC_NAND_ECC_PAGE_SIZE_2048BYTE;

 hnand1.Init.TCLRSetupTime = 0;

 hnand1.Init.TARSetupTime = 0;

 /* hnand1.Config */

 hnand1.Config.PageSize = 2048;

 hnand1.Config.SpareAreaSize = 64;

 hnand1.Config.BlockSize = 64;

 hnand1.Config.BlockNbr = 2048;

 hnand1.Config.PlaneNbr = 2;

 hnand1.Config.PlaneSize = 2048;

 hnand1.Config.ExtraCommandEnable = DISABLE;

 /* ComSpaceTiming */

 ComSpaceTiming.SetupTime = 2;

 ComSpaceTiming.WaitSetupTime = 4;

 ComSpaceTiming.HoldSetupTime = 3;

 ComSpaceTiming.HiZSetupTime = 2;

 /* AttSpaceTiming */

 AttSpaceTiming.SetupTime = 2;

 AttSpaceTiming.WaitSetupTime = 4;

 AttSpaceTiming.HoldSetupTime = 3;

 AttSpaceTiming.HiZSetupTime = 2;

 if (HAL_NAND_Init(&hnand1, &ComSpaceTiming, &AttSpaceTiming) != HAL_OK)

 {

  Error_Handler( );

 }

berendi
Principal

No, I can't, for two reasons.

  1. I don't know what kind of flash and MCU are you using, don't have the datasheets.
  2. HAL functions are too complicated for me to follow, and I have failed to find any documentation so far that explains them in sufficient depth for troubleshooting.

You can however read the FMC register values after HAL_NAND_Init() and check their values against the reference manual and the NAND datasheet.