User FLASH_ERASE not working properly on STM32G071 MCU
I want to write some data into flash memory on STM32G071 MCU as a part of a project. For that, I am using the function 'HAL_FLASHEx_Erase' to erase the pages before writing. While debugging it's working fine. But when I downloaded the code to MCU and started running, the execution stuck somewhere. I have found that the code runs smoothly till the line, CLEAR_BIT(FLASH->CR, FLASH_CR_PER); inside the function. But it didn't execute even the very next line.
How can I resolve the problem?