AnsweredAssumed Answered

write to flash mem stm32f429

Question asked by TARHAN SAMAH on Apr 19, 2018
Latest reply on Apr 20, 2018 by TARHAN SAMAH

hello evrybody, i can write to stm32f103c8/cb with no prblms using hal functions ,

but now i need to write to stm32f429ZI nucleo cart , but no success some times i can what i wrote by coinsidence but this is very strange i dont know where is the prblm in reading or writing here is the code :

i need to write one byte so there is two ways using one byte function or half word function just for lower byte :

 

1-way onebyte way : i cannot write using this function

 

uint8_t  GDT_NUM_CHAR=8;

uint32_t gdt_data_adress=0x081E0000;//LAST sector for STM32429ZI sector 23

uint32_t SectorError;
static FLASH_EraseInitTypeDef EraseInit;

 

HAL_FLASH_Unlock();
EraseInit.TypeErase = FLASH_TYPEERASE_SECTORS;
EraseInit.VoltageRange = FLASH_VOLTAGE_RANGE_3;
EraseInit.Sector =gdt_data_adress;//FLASH_SECTOR_23
EraseInit.NbSectors = 1;

 

if(HAL_FLASHEx_Erase(&EraseInit,&SectorError)==HAL_OK)//we have to erase memory needed space it is a physical issue of eeproms before any writing of data
{
printf("erase suceed");
HAL_Delay(400);
}

FLASH_Program_Byte(gdt_data_adress,GDT_NUM_CHAR);

  HAL_FLASH_Lock();

----->warning:  #223-D: function "FLASH_Program_Byte" declared implicitly

---> L6218E: Undefined symbol FLASH_Program_Byte (referred from keypad.o).

 

 

2-way halfword way

 

uint8_t  GDT_NUM_CHAR=8;

uint16_t  gdt_num=0x0008;

uint32_t gdt_data_adress=0x081E0000;//LAST sector for STM32429ZI sector 23

uint32_t SectorError;
static FLASH_EraseInitTypeDef EraseInit;

 

HAL_FLASH_Unlock();
EraseInit.TypeErase = FLASH_TYPEERASE_SECTORS;
EraseInit.VoltageRange = FLASH_VOLTAGE_RANGE_3;
EraseInit.Sector =gdt_data_adress;//FLASH_SECTOR_23 
EraseInit.NbSectors = 1;

 

if(HAL_FLASHEx_Erase(&EraseInit,&SectorError)==HAL_OK)//we have to erase memory needed space it is a physical issue of eeproms before any writing of data
{
printf("erase suceed");
HAL_Delay(400);
}

 

if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,gdt_data_adress,gdt_num)==HAL_OK)//save GDT num to data adress
 {

printf("write suceed");
HAL_Delay(400);
 }

  HAL_FLASH_Lock();

 

i dont read same value what i wrote to flash ????where is my mistake is it about about adress , i select the last sector to avoid interfering with prgm ,help needed thanks 

Outcomes