cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f0. Is it normal that after erasing flash memory in HAL_FLASH_IRQHandler there is no FLASH_CR_PER clear?

PaulFirs
Visitor

In stm32f0xx_hal_flash.c line 319:

 

 

 

/* Check if there are still pages to erase */
        if(pFlash.DataRemaining != 0U)
        {
          addresstmp = pFlash.Address;
          /*Indicate user which sector has been erased */
          HAL_FLASH_EndOfOperationCallback(addresstmp);

          /*Increment sector number*/
          addresstmp = pFlash.Address + FLASH_PAGE_SIZE;
          pFlash.Address = addresstmp;

          /* If the erase operation is completed, disable the PER Bit */
          CLEAR_BIT(FLASH->CR, FLASH_CR_PER);

          FLASH_PageErase(addresstmp);
        }
        else
        {
          /* No more pages to Erase, user callback can be called. */
          /* Reset Sector and stop Erase pages procedure */
          pFlash.Address = addresstmp = 0xFFFFFFFFU;
          pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
          /* FLASH EOP interrupt user callback */
          HAL_FLASH_EndOfOperationCallback(addresstmp);
          CLEAR_BIT(FLASH->CR, FLASH_CR_PER); // ?????????For example here???????????
        }

 

 

 

After interrupt I expect PER bit to be cleared but it is not, because of this I can't program flash. Currently I clear this bit myself before programming flash, but is there any reason not to do it in HAL_FLASH_IRQHandler?

P.S. I spent a lot of time figuring this out. Maybe I'm not the only one.

0 REPLIES 0