I do a project for STM32f303 and I am a beginner not experienced one. I want to write configuration data in the internal flash.
I used these functions for read and write.
void write_flash (uint32_t Addr, uint8_t Data1, uint8_t Data2 )
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, Addr, ((uint16_t)Data1 | (((uint16_t)Data2)<< 8)) );
uint8_t read_flash (uint32_t Addr)
return *(__IO uint8_t*)Addr;
I tried them and it worked well. I can modify the data and every time I power on the micro I could get my data. My question is -> "Is this a good way for reading from flash memory?" I did not modify the linker script and I did not use a user data section. I just make sure that my code will not reach to the pages of configuration data.
I want to understand the difference in behavior between what I did and the other way like this