AnsweredAssumed Answered

writing half word 16 bits on flash stm32f429ZI

Question asked by TARHAN SAMAH on May 23, 2018
Latest reply on May 24, 2018 by TARHAN SAMAH

Hello evry body , i can write a byte on flash of stm32f429ZI WİTH success . for info i use nucleo 144 and sector 23 the last sector .

 

for example :

 

with these adresses 

uint32_t locip1_adress=0x081E0001;//LAST sector for STM32429ZI sector 23
uint32_t locip2_adress=0x081E0002;//LAST sector for STM32429ZI sector 23
uint32_t locip3_adress=0x081E0003;//LAST sector for STM32429ZI sector 23
uint32_t locip4_adress=0x081E0004;//LAST sector for STM32429ZI sector 23

uint32_t remip1_adress=0x081E0005;//LAST sector for STM32429ZI sector 23
uint32_t remip2_adress=0x081E0006;//LAST sector for STM32429ZI sector 23
uint32_t remip3_adress=0x081E0007;//LAST sector for STM32429ZI sector 23
uint32_t remip4_adress=0x081E0008;//LAST sector for STM32429ZI sector 23

uint32_t ROV_min_adress=0x081E0009;//LAST sector for STM32429ZI sector 23 this data needs two bytes
uint32_t ROV_max_adress=0x081E00B;//LAST sector for STM32429ZI sector 23 this data needs two bytes

 

/* Unlock the Flash to enable the flash control register access *************/
HAL_FLASH_Unlock();

/* Fill EraseInit structure*/
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
EraseInitStruct.Sector = FLASH_SECTOR_23;
EraseInitStruct.NbSectors = 1;
//you need to erase entire sector before write anything
HAL_FLASHEx_Erase(&EraseInitStruct, &SECTORError);//we need to erase the sector before write

HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, locip1_adress,locip1);//write one byte
HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, locip2_adress,locip2);//write one byte
HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, locip3_adress,locip3);//write one byte
HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, locip4_adress,locip4);//write one byte

HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, remip1_adress,remip1);//write one byte// we need to write also all other parameter because we delete all sector 23
HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, remip2_adress,remip2);//write one byte
HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, remip3_adress,remip3);//write one byte
HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, remip4_adress,remip4);//write one byte

HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,ROV_min_adress,Rover_ID_min[0]);//write one 16 bit
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,ROV_max_adress,Rover_ID_max[0]);//write one 16 bit

HAL_FLASH_Lock();

 

 

But in THE HALFWORD writing i have prblm with 16 bit writing looks these adresses are not accepted 

uint32_t ROV_min_adress=0x081E0009;  ----> in my idea for one word ill use 0x081E0009+ 0x081E000A Two bytes --->is it right
uint32_t ROV_max_adress=0x081E00B;-----> WİLL use 0x081E000B+0x081E000C  two bytes 

 

but the data at the reading of  ROV_max_adress are wrong strangely ??

how should i select the adresses separation between them for writing half word can someone give me an example . thanks 

could not find detail about mem data adresses in detail .

 

 

 

Outcomes