2025-02-08 05: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.