2020-11-11 09:57 PM
Hi,
I am using the internal EEPROM of the STM32L151CBT, with SYSCLK 32Mhz.
Access to the EEPROM is done using the HAL functions present in stm32l1xx_hal_flash_ramfunc.c
HAL functions are defined as __RAM_FUNC and placed in the ram segment:
__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DATAEEPROM_ProgramDoubleWord (uint32_t Address, uint64_t Data)
__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DATAEEPROM_EraseDoubleWord (uint32_t Address)
The whole erasing / writing sequence on eeprom is carried out with interrupts disabled. The write function is:
void eeprom_Write_DoubleWord (uint32_t eeAddress, uint64_t Data)
{
__disable_irq ();
if (HAL_FLASHEx_DATAEEPROM_Unlock () == HAL_OK)
{
HAL_FLASHEx_DATAEEPROM_EraseDoubleWord (eeAddress);
HAL_FLASHEx_DATAEEPROM_ProgramDoubleWord (eeAddress, Data);
HAL_FLASHEx_DATAEEPROM_Lock ();
}
__enable_irq ();
}
the eeprom_Write_DoubleWord () data writing cycle is approximately one call every 1 minute.
Everything works correctly even for 15/20 hours, then randomly the processor bus goes into block and then the watch-dog trips, which forces a hardware reset. This is bad for the application as runtime data is lost.
There is any bug in the HAL driver or some precautions to use the sequence correctly
Any help will be highly appreciated. Thanks.
2020-11-12 01:08 AM
Hello @RMari.2 ,
Welcome to the STM32 Community 😊.
Which release of STM32CubeL1 MCU package are you using ?
Please ensure to use the latest version contains update on HAL FLASH driver (from 1.10.0 release).
>> then randomly the processor bus goes into block and then the watch-dog trips, which forces a hardware reset. This is bad for the application as runtime data is lost.
Else, if the issue is not related to the know limitations in the old release, I suggest you to debug and provide a few more details: which release used ? when the problem it occurs, this will help us to reproduce and investigate on this issue.
Imen
2020-11-12 02:13 AM
Good morning, currently I use the firmware STM32CubeFW_L1 V1.10.0 but i also upgraded to version V1.10.2, verifying the code of the 4 HAL functions dedicated to the management of the EEprom, these are identical coded.
HAL_FLASHEx_DATAEEPROM_Unlock()
HAL_FLASHEx_DATAEEPROM_EraseDoubleWord(..)
HAL_FLASHEx_DATAEEPROM_ProgramDoubleWord(...)
HAL_FLASHEx_DATAEEPROM_Lock()
I think it is very unlikely that the problem could be related to a patch of the new HAL version.
It is probably a timing problem in accessing the EEPROM registers or a missing setting in write management registers.
I hope there is a suggestion on the solution of the problem.
Thank you so much