2018-05-23 01:05 AM
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 23uint32_t locip3_adress=0x081E0003;//LAST sector for STM32429ZI sector 23uint32_t locip4_adress=0x081E0004;//LAST sector for STM32429ZI sector 23uint32_t remip1_adress=0x081E0005;//LAST sector for STM32429ZI sector 23
uint32_t remip2_adress=0x081E0006;//LAST sector for STM32429ZI sector 23uint32_t remip3_adress=0x081E0007;//LAST sector for STM32429ZI sector 23uint32_t remip4_adress=0x081E0008;//LAST sector for STM32429ZI sector 23uint32_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 writeHAL_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 bytesbut 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 .
Solved! Go to Solution.
2018-05-24 07:39 AM
Hello
doumandjisamah
,To know when you have 16-bit aligned address, you can check LSB bit which must be 0, thus:
0
, 2 = 0b0010
, 4 = 0100
, 6 = 0b0110
00
;4 = 0b0100
;8 = 0b1000
In your case, address
0x081E0009
is odd, LSB =1 => not 16-bit aligned, while0x081E000A
or0x081E000C
is even number, LSB = 0 => 16-bit aligned.If we go back to flash write process:
Hope it is clear now.
Best regards,
Tilen
2018-05-23 01:22 AM
Dear
,please check FLASH_SR register for possible errors when programming.
Address must be 16-bits aligned, which is not your case.
uint32_t ROV_min_adress=0x081E0009;�?
should be
uint32_t ROV_min_adress=0x081E0008; //Either 8 and then it will use 8 + 9 bytesuint32_t ROV_min_adress=0x081E000A; //Or A and then it will use A + B bytes�?�?
Best regards,
Tilen
2018-05-23 06:23 AM
Hello Mister Tilen , thanks for answering but i think you didnt understand my question ,
i have two datas to save for example:
Rover_ID_min[0]=0x0012;
Rover_ID_max[0]=
0x0044;
in these adresses
uint32_t ROV_min_adress=0x081E0009;
uint32_t ROV_min_adress=0x081E000B;
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,ROV_min_adress,Rover_ID_min[0]);//write one 16 bit
,------> Ä°LL use 9 and A
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,ROV_max_adress,Rover_ID_max[0]);//write one 16 bit
----->Ä°LL USE B AND C
SO WHY THERE Ä°S A MÄ°STAKE ON MY READED DATA since i separate wel the adresses
2018-05-23 06:52 AM
Dear
doumandjisamah
,what are the values you read back in this case?
Please note, addresses0x081E0009 and0x081E000Bare not 16-bits aligned and you cannot program to these addresses as 16-bits (HALFWORD). You may use addresses0x081E0008
and
0x081E000A or 0x081E000Aand
0x081E000C or use byte programming width.Best regards,
Tilen
2018-05-23 07:36 AM
i read diferent values from what i wrote ;
what is the meaning of 16 bits alligned where can i see the memory map details ? to understand how to select my adresses i just can see on memory map sector 23 0x081E 0000 -0X081F FFFF
Ä°F Ä° SELECT
uint32_t ROV_min_adress=0x081E0010;
uint32_t ROV_max_adress=0x081E0012;
Ä°T WORKS i just want the explanation about the adresses
2018-05-23 07:38 AM
according to the doc RM 0090 PAGE 77
2018-05-23 08:23 AM
Thanks much i got it a little thanks
2018-05-23 08:24 AM
even levels of memory got it thanks
2018-05-24 07:39 AM
Hello
doumandjisamah
,To know when you have 16-bit aligned address, you can check LSB bit which must be 0, thus:
0
, 2 = 0b0010
, 4 = 0100
, 6 = 0b0110
00
;4 = 0b0100
;8 = 0b1000
In your case, address
0x081E0009
is odd, LSB =1 => not 16-bit aligned, while0x081E000A
or0x081E000C
is even number, LSB = 0 => 16-bit aligned.If we go back to flash write process:
Hope it is clear now.
Best regards,
Tilen
2018-05-24 07:47 AM
much much cleaaaaaaaaaaaaaar thanks much