2025-02-08 5:54 PM
ive been trying to use the two option bytes available for the user. but i have not been able to get it to Write to them i code.
editing the bytes via cubeProgrmmer then reading them with the following:
uint8_t userByte0 = HAL_FLASHEx_OBGetUserData(OB_DATA_ADDRESS_DATA0);
uint8_t userByte1 = HAL_FLASHEx_OBGetUserData(OB_DATA_ADDRESS_DATA1);
That works as expected. But trying to write to them does not work.
FLASH_OBProgramInitTypeDef obConfig;
HAL_FLASHEx_OBGetConfig(&obConfig);
obConfig.OptionType = OPTIONBYTE_USER; // Specify we are modifying user option bytes
obConfig.USERType = OB_USER_DATA0; // Select User Data Byte 0
obConfig.USERConfig = 0x55; // Set the value (change as needed)
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
HAL_FLASHEx_OBProgram(&obConfig);
HAL_FLASH_OB_Launch();
I tired to check the bytes via cubeProgrammer but does not seem to be present.
2025-02-20 7:14 AM
Hi @tje7415 ,
2 recommendations:
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
-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.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.