STM32H563 Flash Erase Program sample fails in Keil
I create sample code for FLASH Erase Program on both mdk arm and stm32cubeide. Using the sample hardware(stm32h563ZITx develop board), the sample code runs correctly on stm32cubeide, but will enter Error hander when doing Flash operation in keil debug mode.:
if (HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError) != HAL_OK)
{
while (1)
{
Error_Handler();
}
}
The C code for two project are the same. The only difference is IDE.
This issue only occurs in debug mode. If I download the code into flash without entering debug mode, the code will successfully run.
By debugging, I find FLASH_NS->NSSR was set as 0x0040000 when I get into the main function of debug mode in Keil,
while FLASH_NS->NSSR is 0 when I debug on stm32cubeIDE. Then I try to manually clear FLASH_NS->NSSR by setting
FLASH->NSCCR as 0x40000.But there will be following bug.
