Skip to main content
Associate
June 20, 2024
Question

STM32 H563 internal flash can not use interrupt mode ?

  • June 20, 2024
  • 6 replies
  • 1703 views

hello all,  

         when I use HAL_FLASHEx_Erase() to erase sectors, it is ok! But when I use HAL_FLASHEx_Erase_IT() interrupt mode to erase sectors, it fails!  It seems the interrupt not occuring!

          if I need to do more settings for flash interrupt mode? 

         Following is my code :

 

{

HAL_FLASH_Unlock();

EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
EraseInitStruct.Banks = 2;
EraseInitStruct.Sector = (DEMO_FLASH_ADDRESS - FLASH_ONCHIP_BASE) / FLASH_SECTOR_SIZE;
EraseInitStruct.NbSectors = 1;

//HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError);
HAL_FLASHEx_Erase_IT(&EraseInitStruct);

HAL_FLASH_Lock();

}

void FLASH_IRQHandler(void)
{
    HAL_FLASH_IRQHandler();
}

 

}

This topic has been closed for replies.

6 replies

Associate III
June 20, 2024

Make sure that the flash interrupt is enabled in your NVIC (Nested Vectored Interrupt Controller) settings. This typically involves calling the appropriate HAL function to enable the interrupt, such as HAL_NVIC_EnableIRQ(FLASH_IRQn)

yimiAuthor
Associate
June 20, 2024

thanks for you quickly replying. I use following to enable the interrupt in the initialization stage:

void FlashInit(void)

{

      /* Enable NVIC for FLASH Interuption */
     HAL_NVIC_SetPriority(FLASH_IRQn, 8, 0);
     HAL_NVIC_EnableIRQ(FLASH_IRQn);

}

And  I  take one day on this topic!  I find in the Web, less informations about  HAL_FLASHEx_Erase_IT() and HAL_FLASH_Program_IT() to operate the internal flash.

any other suggestion? 

 

Thanks!

Associate III
June 20, 2024

It seems you're not calling the FlashInit() function before HAL_FLASHEx_Erase_IT(&EraseInitStruct). Ensure to include FlashInit() to enable NVIC for FLASH Interruption before initiating the erase operation:

yimiAuthor
Associate
June 20, 2024

Yes,  I call FlashInit() before HAL_FLASHEx_Erase_IT(&EraseInitStruct)! 

 

And I retest polling mode ,everything, including read, erase, write are both good!

 

yimiAuthor
Associate
June 20, 2024

and I debug HAL_FLASHEx_Erase_IT() --> FLASH_Erase_Sector(), find after executing line991, it cause a PGSERR interrupt,  which means programming sequence error. But it also not causes an interrupt, I do not know why? 

 

yimi_0-1718891124451.png

Joe WILLIAMS
ST Employee
June 22, 2024

Hi yimi

 

This post has been escalated to the ST Online Support Team for additional assistance.  We'll contact you directly.

 

Regards

Joe 

STMicro Support