Question
PGERR writing user data option bytes STM32F103RE
Posted on March 03, 2015 at 18:44
Hi all,
I am trying to read and write the STM32F103 user data bytes (Data0 and Data1 in Table 8 of STM32F10xxx PM0075 Programming manual).I wrote this code to set Data0 to value 0x1B: FLASH_UnlockBank1(); // step 1 flashStatus = FLASH_ProgramOptionByteData(0x1FFFF804, 0x1b); // step 2 FLASH_LockBank1(); // step 3and the result after step 2 is flashStatus == FLASH_ERROR_PGand the memory at 0x1FFFF804 has not changed.Is there more that I should be doing to establish the proper context for executing step 2?When I succeed, will the change to Data0 be immediately readable, or does the CPU need to go through a reset cycle for the updated option bytes to be visible?At the assignment moment within FLASH_ProgramOptionByteData(), just before *address=data, we have FLASH_CR==OPTWRE|OPTPG and all the other control bits are zero.Before the assignment, FLASH_SR==EOP; after the assignment, FLASH_SR==PGERR|EOP.The FLASH_* functions are from stm32f10x_flash.c V3.6.1 .Thank you for any advice or example code.Owen #flash #option-bytes