cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H745XI Flash Erase and Flash Write does not work

We are implementing and Safety project and cannot use the inbuilt Boot-loader provided by ST .

I started developing the logic but the STM32H745XI Flash Erase and Flash Write does not work .

The follows .

{
/* Unlock the Flash to enable the flash control register access */
FlashFunc_StatusOfFlashCmd = HAL_ERROR;
FlashFunc_StatusOfFlashCmd = HAL_FLASH_Unlock();
 
FlashFunc_StatusOfFlashCmd = HAL_FLASHEx_Unlock_Bank2();
if (FlashFunc_StatusOfFlashCmd == HAL_OK)
{
FlashFunc_StatusOfFlashCmd = HAL_ERROR;
FlashFunc_StatusOfFlashCmd = HAL_FLASH_OB_Unlock();
if (FlashFunc_StatusOfFlashCmd == HAL_OK)
{
FlashFunc_StatusOfFlashCmd = HAL_ERROR;
/* Fill EraseInit structure*/
EraseInitStruct.TypeErase     = FLASH_TYPEERASE_MASSERASE;
EraseInitStruct.VoltageRange  = FLASH_VOLTAGE_RANGE_4;
EraseInitStruct.Banks         = FLASH_BANK_2;
 
__disable_irq();
FlashFunc_StatusOfFlashCmd =HAL_FLASHEx_Erase(&EraseInitStruct, &EraseError);
 
if(FlashFunc_StatusOfFlashCmd != HAL_OK)
{
	FLASH_Erase_Sector(FLASH_SECTOR_7, FLASH_BANK_2,FLASH_VOLTAGE_RANGE_4);
}
else
{
	__disable_irq();
	for(FlashFunc_u32DataWrite=0;FlashFunc_u32DataWrite < (uint32_t)1024u;FlashFunc_u32DataWrite++)
	{
	FlashFunc_StatusOfFlashCmd = HAL_FLASH_Program((FLASH_TYPEPROGRAM_FLASHWORD),FlashFunc_u32FlashAddr, FlashFunc_u32WriteData);
	FlashFunc_u32FlashAddr+=32;
	FlashFunc_u32WriteData+=32;
	}
}
 
}
}
}

1 REPLY 1
Pavel A.
Evangelist III

Please look at lines 18-19. Will the if condition ever be true?

-- pa