STM32 H563 internal flash can not use interrupt mode ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-20 3:36 AM
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();
}
}
- Labels:
-
STM32Cube MCU Packages
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-20 3:41 AM
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-20 3:47 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-20 5:29 AM
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-20 5:32 AM
Yes, I call FlashInit() before HAL_FLASHEx_Erase_IT(&EraseInitStruct)!
And I retest polling mode ,everything, including read, erase, write are both good!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-20 6:49 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-21 5:46 PM
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
