STM32G4 using HAL Lib to read eeprom, when wirte to eeprom many times, the SYSTICK's tick variable will be changed randomly
hi,
for our project,we used firmware package was STM32CubeG4 Firmware Package V1.6.0 / 05-June-2024.
IDE: MDK 5.39
MCU: STM32G473MET6 EEPROM: 24LC256
we already check the page write opreation, ensure the boundaries and size of each write (less than or equal to the page size)
we have also tried DMA and IT, but they will affect SYSTICK
this our test code
uint32_t EEPROM_WriteBytes(uint16_t address, uint8_t *pData, uint16_t length)
{
while( (HAL_GetTick() -LastWriteTick) <=6);
LastWriteTick = HAL_GetTick();
if (HAL_I2C_Mem_Write(&hi2c4, _24LCXX_I2C_ADDRESS, address, I2C_MEMADD_SIZE_16BIT,
pData, length, HAL_MAX_DELAY) != HAL_OK)
{
return 0;
}
uint32_t EEPROM_ReadBytes(uint16_t address, uint8_t *pData, uint16_t length)
{
while( (HAL_GetTick() -LastWriteTick) <=6);
if (HAL_I2C_Mem_Read(&hi2c4, _24LCXX_I2C_ADDRESS, address, I2C_MEMADD_SIZE_16BIT,
pData, length, HAL_MAX_DELAY) != 0)
{
return 0;
}
return 1;
}
