Showing results for 
Search instead for 
Did you mean: 

STM32L4R9I_EVAL and TouchGFX EEPROM issue


I'm using the STM32L4R9I_Eval board with the STM32 Cube IDE (v 1.12.1) and the TouchGFX interface (v 4.21.3).  I'm having an issue with EEPROM... I grabbed the STM32 provided BSP EEPROM code and am basically reading/writing a structure that contains some user preferences.  I'm using 0xA0 as the EEPROM I2C address and the read/write address of 0x50.  I know the code works as I've tested the reading and writing functions at different steps in the main code.  I've even done the write and pressed the board reset button and when the program starts again, it reads in the correct values from the last save.  Once I call osKernelStart() to get everything going, I get a HAL_ERROR return whether trying to read or write.

I've tried several suggestions online but I'm still missing something:

I've used the void TouchGFXHAL::endFrame() function to check a boolean to see if I need to save the preferences to EEPROM and make a call to disableInterrupts, try the save, and then call enableInterrupts again. I've put the writing to EEPROM into its own task and used a boolean to tell it when to save as well.  

Also note that once in a while, I can get it to not error out and do what it's supposed to do but it's very rare.

The basic function for saving is simple and illustrated below - aziSettings is a structure with a few variables in it

#define EEPROM_I2C_ADDRESS_A01           0xA0
#define EEPROM_WRITE_ADDRESS1   0x50

void eeprom_SaveSettings(void)
uint32_t buffsize = sizeof(aziSettings);
    if (BSP_EEPROM_WriteBuffer((uint8_t *) &aziSettings, EEPROM_WRITE_ADDRESS1, buffsize) != EEPROM_OK)

Would love to get this working consistently so any suggestions would be appreciated!