2021-01-03 07:57 AM
Information:
- STM32F777ZI
- Dual mode enabled
- Application in BANK 1. Nothing in BANK 2.
- For simplicity I do NOT turn on: I/D caches, ART and Prefetch, MPU.
Scenario:
1) Power up.
2) I execute the function. CPU sometimes stalls, sometimes not, sometimes in the middle of erase
3) I execute for the seconds time. CPU does NOT stall.
4) I execute again. Again no stall. No stall any more.
It appears that the first erase stalls the CPU.
I use simple audio to hear that CPU stalls (buzzer toggled by interrupt in pattern 100ms ON / 100ms OFF).
Question:
Is this a silicon bug? Or maybe I do something wrong.
I have found 2 other topics on the forum but without solution.
bool Platform_EraseBank2(void)
{
uint32_t faultySector;
FLASH_EraseInitTypeDef EraseInitStruct =
{
.TypeErase = FLASH_TYPEERASE_MASSERASE,
.Banks = FLASH_BANK_2,
.VoltageRange = FLASH_VOLTAGE_RANGE_3,
};
bool res = (HAL_FLASH_Unlock() == HAL_OK);
if(res)
{
extern void Audio_PlayAlarm( const bool state );
Audio_PlayAlarm(true);
Dbg_Printf("%s: START\n", __func__);
res = (HAL_FLASHEx_Erase(&EraseInitStruct, &faultySector) == HAL_OK);
Dbg_Printf("%s: ERASED\n", __func__);
Audio_PlayAlarm(false);
HAL_FLASH_Lock();
}
return res;
}
2021-01-03 01:37 PM
Update
I have noticed that CPU stalls if the erase is started shortly after restart (up to 2 seconds). If I execute the function 4 seconds after restart then there is no problem. Even with caches, ART, MPU enabled. May it be an problem of internal voltage regulator?