AnsweredAssumed Answered

STM32F1XX HAL_FLASH_Program dont support 8bytes? or go 16bytes space waste.

Question asked by Nicolas Felipe on Jun 26, 2017
Latest reply on Jun 27, 2017 by Tilen MAJERLE

Hi, im trying to program (8byte) 500 lenght buffer into Internal an STM32F103xx microcontroller, i know how to write but


char receive_data[500]; / Char Belongs to 8bytes


but in STM32F1xx_hal_flash.h


#define FLASH_TYPEPROGRAM_HALFWORD ((uint32_t)0x01) /*!<Program a half-word (16-bit) at a specified address.*/
#define FLASH_TYPEPROGRAM_WORD ((uint32_t)0x02) /*!<Program a word (32-bit) at a specified address.*/
#define FLASH_TYPEPROGRAM_DOUBLEWORD ((uint32_t)0x03) /*!<Program a double word (64-bit) at a specified 


and 8bytes?


in other series like STM32F4XX we can find 8bytes support.


 if(TypeProgram == FLASH_TYPEPROGRAM_BYTE)00190     {00191       /*Program byte (8-bit) at a specified address.*/00192       FLASH_Program_Byte(Address, (uint8_t) Data);00193     }



i was tempted to addit to this STM32F1XX function but dont look any 8byte friendly with the nbiterations var.


if(status == HAL_OK)
/* Program halfword (16-bit) at a specified address. */
nbiterations = 1;
else if(TypeProgram == FLASH_TYPEPROGRAM_WORD)
/* Program word (32-bit = 2*16-bit) at a specified address. */
nbiterations = 2;
/* Program double word (64-bit = 4*16-bit) at a specified address. */
nbiterations = 4;

for (index = 0; index < nbiterations; index++)
FLASH_Program_HalfWord((Address + (2*index)), (uint16_t)(Data >> (16*index)));

#if defined(FLASH_BANK2_END)
if(Address <= FLASH_BANK1_END)
#endif /* FLASH_BANK2_END */
/* Wait for last operation to be completed */
status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);

/* If the program operation is completed, disable the PG Bit */
#if defined(FLASH_BANK2_END)


for example im gonna program : 


char strJsonExtracted[] = "{\"set\":\"mf\",\"d\":\"2\",\"m\":\"22\",\"a\":\"17\",\"h\":\"18\",\"s\":\"45\"}";

(8  bytes buffer).



if the FLASH_TYPEPROGRAM_HALFWORD is used i guess lot of space will get wasted because will se 16bytes when needed is just 8bytes and , am i wrong? or this would be the best option? thanks.