2020-10-13 01:27 AM
Dear,
I am setting RDP to level 1 in my application, After setting it I call System reset HAL_NVIC_SystemReset();
After reset I am expecting the MCU is locked, but it seems I read in code the MCU is still in level 0 so the procedure of setting RDP to level 1 is repeating. Only power disconnect locks the processor to level 1.
Any solution?
Best regards, Jan.
HAL_FLASHEx_OBGetConfig(&flashTemp);
if(OB_RDP_LEVEL_0 == flashTemp.RDPLevel)
{
HAL_FLASH_OB_Unlock();
HAL_FLASHEx_OBGetConfig(&pOBInit);
pOBInit.RDPLevel = 0xBB;
pOBInit.WRPState = OB_WRPSTATE_ENABLE;
HAL_FLASHEx_OBProgram(&pOBInit);
HAL_FLASH_OB_Lock();
HAL_NVIC_SystemReset();
}
2020-10-13 06:29 AM
What chip?
Look at the code:
You need to add:
pOBInit.OptionType = OPTIONBYTE_RDP | OPTIONBYTE_WRP;
if you want to set those options.
2020-10-13 06:34 AM
STM32L071
2020-10-13 07:00 AM
2020-10-14 03:24 AM
Hi @Community member ,
Did you added the line suggested by @TDK ? Does it work this time?
If yes, please mark his reply as Best answer (click on "Select as Best").
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2020-10-14 07:34 AM
Funny how problems occur in pairs -- somewhat related.
You might probably need to reload the option bytes after programming, see Reloading Option bytes by software subchapter in RM.
JW