STM32F103 read out protection
Hello all,
I have developed a code for stm32f103, which works fine.
During code execution, some device configuration data is Read & written into flash (works fine).
But when i enable read out protection, the code doesn't work.
My understanding is that when read out protection is enabled, code is not able to read/write data from flash, in result it doesn't initialize the configuration parameter of device.
i tried to enable to the read out protection by both ways.
......from st-link utility tool
or
......by writing in code itself.
/***************code for read out protection****************/
uint8_t ReadProtectionConfig(uint8_t ProtectionLevel)
{
uint8_t status = 0;
FLASH_OBProgramInitTypeDef OB_Init;
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
OB_Init.OptionType = OPTIONBYTE_RDP;
if (ProtectionLevel == 0)
{
OB_Init.RDPLevel = OB_RDP_LEVEL_0;
}
else if (ProtectionLevel == 1)
{
OB_Init.RDPLevel = OB_RDP_LEVEL_1;
}
else
{
status = 1;
return status;
}
HAL_FLASHEx_OBProgram(&OB_Init);
HAL_FLASH_OB_Launch();
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
return status;
}
in both case read out protection works ok.
Post edited to adhere community guidelines.
please guide me on this.
