2020-03-10 07:34 AM
Hi,
This is to request clarification on doubts regarding the storage of data in the non-volatile memory of the STM32G030C6T6 micro controller ... from what I see in the micro controller's technical sheet, it does not have EEPROM memory, since FLASH memory is used both to save the code and to store data.
I have two routines to write and read respectively from FLASH; but they don't work, and I get an error in the statement: "HAL_FLASHEx_Erase (& EraseInitStruct, & SECTORError);"
Could you please help me to identify the error, or to know another way to record data in the non-volatile memory of the STM32G030C6T6
Below is attached the code used in both routines
Thank you so much
/* WRITE IN FLASH MEMORY */
void writeToFLASH (uint32_t address, uint32_t value){
HAL_StatusTypeDef flash_ok;
flash_ok = HAL_ERROR;
while (flash_ok != HAL_OK){
flash_ok = HAL_FLASH_Unlock();
// flash_ok = HAL_FLASHEx_Erase(&EraseInitStruct, &SECTORError);
flash_ok = HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, address, value);
flash_ok = HAL_FLASH_Lock();
}
}
/* READ FROM FLASH MEMORY */
uint32_t readFromFLASH (uint32_t address){
return (*(__IO uint32_t *)address);
}
2020-03-10 08:20 AM
>> I get an error in the statement: "HAL_FLASHEx_Erase (& EraseInitStruct, & SECTORError);"
What does the error specifically say? That you haven't defined the variables/structures?
Usually one would have a structure/array of data to be saved into a flash sector, so the write/erase can be done efficiently.
2020-03-10 12:17 PM
And how is EraseInitStruct defined? You need to populate it with what you're trying to do.