STM32L0xx hangs up by reading EEPROM
Hello!
I have these code to store/read data in the EEPROM of my STM32L031K6..
The write function works, the data is saved in flash correctly...
When i want to read the data back, i falling in the HardFault Handler.... :\
This is my Code:
eeprom.h
#define EEPROM_BASE_ADDRESS 0x08080000UL
HAL_StatusTypeDef writeEEPROMByte(uint32_t address, uint8_t data)
{
HAL_StatusTypeDef status;
uint32_t eepromAddress = address + EEPROM_BASE_ADDRESS;
HAL_FLASHEx_DATAEEPROM_Unlock();
status = HAL_FLASHEx_DATAEEPROM_Program(TYPEPROGRAMDATA_BYTE, eepromAddress, data);
HAL_FLASHEx_DATAEEPROM_Lock();
return status;
}
uint8_t readEEPROMByte(uint32_t address)
{
uint8_t data = 0;
uint32_t eepromAddress = address + EEPROM_BASE_ADDRESS;
data = *(__IO uint32_t *)eepromAddress;
return data;
}i think, the convertion from uint32_t to uint8_t is wrong, but it works to write the data...
