STM32F407 Sector Flash Erase forces WWDG reset
Hello all,
I am facing following problem:
Trying to perform an erase operation of a flash sector forces a WWDG reset. The WWDG is initialized with following settings:
hwwdg.Instance = WWDG;
hwwdg.Init.Prescaler = WWDG_PRESCALER_8;
hwwdg.Init.Window = 127;
hwwdg.Init.Counter = 127;
hwwdg.Init.EWIMode = WWDG_EWI_ENABLE;For my understanding, the WWDG acts as timeout watchdog only with this settings and can be refreshed no matter of the counter- window relation. Is this correct?
The early wakeup interrupt handles the refresh of the counter.
Calling the function FLASH_Erase_Sector to erase one sector from the HAL library (stm32f4xx_hal_flash_ex.c) leads to a MCU reset. From RCC it is recognizable that the reset was caused by WWDG.
Placing a breakpoint during debug session at the function executed after the FLASH_Erase_Sector does not cause a reset. Here is a code snippet from the HAL code, to show the breakpoint placement:
for(index = pEraseInit->Sector; index < (pEraseInit->NbSectors + pEraseInit->Sector); index++)
{
FLASH_Erase_Sector(index, (uint8_t) pEraseInit->VoltageRange);
/* Wait for last operation to be completed */
/* BREAKPOINT IS PLACED HERE */
status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
/* If the erase operation is completed, disable the SER and SNB Bits */
CLEAR_BIT(FLASH->CR, (FLASH_CR_SER | FLASH_CR_SNB));
if(status != HAL_OK)
{
/* In case of error, stop erase procedure and return the faulty sector*/
*SectorError = index;
break;
}
}Did anyone experience a similar behavior and found a fix?
Thank you, any help is kindly appreciated.
