2018-06-07 12:16 AM
Hi.
Now, I can unlock flash memory for data save by erase page size 800(2kbyte) and I would like to data save for binary.
Example
0x0800800 for '1'
0x0800801 for '2'
0x0800802 for '3'
How should I do?
below my code for erase page size so I would like to write binary for flash memory
&sharpdefine ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base address of Page 0, 2 Kbytes */
&sharpdefine ADDR_FLASH_PAGE_1 ((uint32_t)0x08000800) /* Base address of Page 1, 2 Kbytes */uint32_t READ_FLASH(uint32_t Address)
{ return *(uint32_t *)Address;}void WRITE_FLASH(uint32_t Data, uint32_t Address, uint32_t StartAddress, uint32_t EndAddress)
{ HAL_FLASH_Unlock(); EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES; EraseInitStruct.PageAddress = (uint32_t)Address; EraseInitStruct.NbPages = (EndAddress - StartAddress)/FLASH_PAGE_SIZE;HAL_FLASHEx_Erase(&EraseInitStruct, &Error);
HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, Address, Data); HAL_FLASH_Lock();}#flash-storage #stm-mcu #stm32 #flash-offset ##stm32f #hal-flash #flash-sector