Option byte RDP=1 STM32F0
I want to set Readprotectionlevel=1. After the initialisation i can't see toggling of GPIO_PIN_7. The function HAL_FLASH_OB_Launch(); causes problems. When commenting out the function HAL_FLASH_OB_Launch() the while(1) loop will be reached. Is there anything wrong setting RDP=1 like this ? I use HAL_DRIVER. I got the same problem with STD_PERIPHERAL_DRIVER. Tools: Keil 4.73, EWARM 7.2, ST-LINKV2
void
MX_Flash_Init(void
) { FLASH_OBProgramInitTypeDef Optbyte; HAL_FLASHEx_OBGetConfig(&Optbyte);// read out RDPLvL
if
(Optbyte.RDPLevel ==RESET){// Lvl 0 = 0, Lvl 1,2 =1
Optbyte.OptionType=OPTIONBYTE_RDP;// select RDP optionbyte
Optbyte.RDPLevel=OB_RDP_LEVEL_1;// select RDP level 1
HAL_FLASH_Unlock();// unlock Flash
HAL_FLASH_OB_Unlock();// unlock Optionbytes
HAL_FLASHEx_OBProgram(&Optbyte);// set RDP=1
HAL_FLASH_OB_Launch();// write OB to Flash and reset
} HAL_FLASH_OB_Lock();// Lock Optionbytes
HAL_FLASH_Lock();// lock Flash
}int
main(void
) { MX_GPIO_Init(); MX_Flash_Init();while
(1
) { GPIOA->ODR^=GPIO_PIN_7; } } #flash #option-bytes #stm32f0