2025-08-28 11:12 PM
Hi everyone,
I’m working on an STM32U3 project and ran into an issue where flash erase was failing with error code 0x00000080 on page erase, even though the option bytes and addresses appeared correct.
After debugging, I found that explicitly setting the voltage scaling to PWR_REGULATOR_VOLTAGE_SCALE1 before flash erase resolved the issue. The working sequence I use is:
HAL_FLASH_Unlock();
HAL_StatusTypeDef status = HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);
if(status != HAL_OK)
{
return status;
}
EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
EraseInitStruct.Banks = BankNumber;
EraseInitStruct.Page = FirstPage;
EraseInitStruct.NbPages = NbOfPages;
if (HAL_FLASHEx_Erase(&EraseInitStruct, &PageError) != HAL_OK)
{
return status;
}
This step wasn’t required on my Nucleo board but was essential on my custom hardware.
My questions now are:
Is it safe and recommended to keep the voltage scaling at SCALE1 permanently after flash erase, or should I revert it to a lower scale for power saving?
If switching back to a lower scale after flash operations, are there any precautions or delays needed during the transition?
Are there any additional best practices around voltage scaling and flash erase/programming on STM32U3 devices that I should be aware of?
Thanks in advance for your help!
Rakesh