cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 H563 internal flash can not use interrupt mode ?

yimi
Associate II

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();
}

 

}

6 REPLIES 6
Shreayas_Acharaya
Associate III

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)

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!

Shreayas_Acharaya
Associate III

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:

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

 

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

 

yimi
Associate II

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

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