2018-10-08 01:31 AM
Hi,
I am having a problem with using internal EEPROM memory for saving data. I can read data only from BASE adress of EEPROM. I can not write to EEPROM or read form any other place in EEPROM.
MY simple code:
#define FLASH_EEPROM_BASE ((uint32_t)(FLASH_BASE + 0x80000U)) /*!< FLASH EEPROM base address in the alias region */
uint8_t eeprom;
/*************************************/
/* unlock EEPROM*/
HAL_FLASHEx_DATAEEPROM_Unlock();
/* Clear flags*/
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP|FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_SIZERR | FLASH_FLAG_OPTVERR );
/* 1) I read from Base - it works fine*/
eeprom=*(volatile uint8_t *) FLASH_EEPROM_BASE; //now I can read the value from eeprom correctly
/* 2) want to write to eeprom - fails*/
HAL_FLASHEx_DATAEEPROM_Program(FLASH_TYPEPROGRAMDATA_BYTE,FLASH_EEPROM_BASE,0x11); // now the writing values to eeprom fails
/* 3 ) read form another place - fails*/
eeprom=*(volatile uint8_t *) FLASH_EEPROM_BASE+7; // I read absolutely differnet values than it should be
I use this procedure on STM32L071 and it works fine, Do not know what I make wrong here.
Thank you for help. Jan.
2018-10-08 02:00 AM
Didn't you mean
eeprom=*(volatile uint8_t *)(FLASH_EEPROM_BASE+7);
which is different from yours given operators precedence.
JW
2018-10-08 08:04 AM
you are Genius:smiling_face_with_smiling_eyes: !
Thanks, Jan.