I've got an STM32L073RZ and I'm attempting to write a 4 byte value to the internal 6 KB EEPROM. I'm running MbedOS 5.11.4 but attempting to use the HAL for this. Here's the code:


float calibrationFactor = 13000.0;
uint32_t calibrationFactor_bits;

LOG("Store float in 32 bits");
memcpy(&calibrationFactor_bits, &calibrationFactor, sizeof(uint32_t));

LOG("Unlock EEPROM");

LOG("Write to EEPROM");
HAL_StatusTypeDef success = HAL_FLASHEx_DATAEEPROM_Program(FLASH_TYPEPROGRAM_WORD, DATA_EEPROM_BASE, calibrationFactor_bits);
LOG("HAL_StatusTypeDef: %d", success);


The program seems to hang when writing to the EEPROM as the function HAL_FLASHEx_DATAEEPROM_Program never returns. As far as I'm aware I'm not doing anything wrong but obviously I must be. Does anyone have any pointers?

EDIT: I've now also tried a code snippet from the STM32L073RZ reference manual, still with the same issue:

*(uint32_t *)(DATA_EEPROM_BASE) = calibrationFactor_bits;
  • 2
    \$\begingroup\$ "Hangs" isn't really a useful problem report - use the debugger to figure out where it is sitting, for example in an infinite loop or in the hard fault handler. You may want to try something simple without mbed os. \$\endgroup\$ Apr 5, 2019 at 16:26

1 Answer 1


Can you try to put the line below at the start of your EEPROM function,

ScopedRomWriteLock make_rom_writable;

then call HAL_FLASHEx_DATAEEPROM_Program.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.