2017-09-22 12:07 AM
HELLO I USE STM32F100RB
I WANT write and read from flash mem :
static HAL_StatusTypeDef FLASH_OB_ProgramData(uint32_t Address, uint8_t Data);
static HAL_StatusTypeDef test3;
/********************FLASH MEMORY******************************/ //WRITE DATA TO FLASH MEMORY
/* Unlock the Flash to enable the flash control register access *************/ HAL_FLASH_Unlock(); /* Unlock the Options Bytes *************************************************/ HAL_FLASH_OB_Unlock();FLASH_PageErase(0);//uint32_t PageAddress HAL_FLASHEx_OBErase(); test3=FLASH_OB_ProgramData(0x080000FFU,0x12);
//HAL_FLASH_OB_Launch();//reserts the system
HAL_FLASH_OB_Lock(); HAL_FLASH_Lock(); //READ THE DATA FROM FLASH MEMORY flash_data=HAL_FLASHEx_OBGetUserData(0x080000FFU);
/********************FLASH MEMORY******************************/
but the software doesnt compile
SDT_LCD_KEYPAD\SDT_LCD_KEYPAD.axf: Error: L6218E: Undefined symbol FLASH_OB_ProgramData (referred from main.o). ?????
is there someone leaved this situation can u help me find solution pl zdid i forget something
Solved! Go to Solution.
2017-09-22 01:35 PM
Something along the lines of
uint32_t Addr = 0x08004000; // Unused area
uint32_t PageError;FLASH_EraseInitTypeDef EraseInit = { 0 };HAL_FLASH_Unlock();
EraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
EraseInit.PageAddress = Addr;EraseInit.NbPages = 1;HAL_FLASHEx_Erase(&EraseInit, &PageError);
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, Addr, 0x1234);
HAL_FLASH_Lock();
Make sure you drop the stm32f1xx_hal_flash.c and stm32f1xx_hal_flash_ex.c into your project to compile, and you adjust stm32f1xx_conf.h to include the flash components.
2017-09-22 05:20 AM
Hi,
I think that your application does not include object, source or libraries including this function.
You should review your project configuration and make sure that your project contains all the required library source files.Have a look to the working example within STM32CubeF1 firmware package to check configuration and implementation.
Best Regards
Imen
2017-09-22 11:18 AM
The main FLASH region is *not* part of the Options Bytes
Writing/Erasing 0x080000FFU also has the high probability of destroying the code you are running.
A review of the Reference Manual might also significantly improve your level of understanding.
There should be specific FLASH examples in the example source under the Cube/HAL tree
2017-09-22 01:35 PM
Something along the lines of
uint32_t Addr = 0x08004000; // Unused area
uint32_t PageError;FLASH_EraseInitTypeDef EraseInit = { 0 };HAL_FLASH_Unlock();
EraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
EraseInit.PageAddress = Addr;EraseInit.NbPages = 1;HAL_FLASHEx_Erase(&EraseInit, &PageError);
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, Addr, 0x1234);
HAL_FLASH_Lock();
Make sure you drop the stm32f1xx_hal_flash.c and stm32f1xx_hal_flash_ex.c into your project to compile, and you adjust stm32f1xx_conf.h to include the flash components.
2017-10-12 01:24 AM
thanks so muchhh
2017-10-12 03:12 AM
works perfectlyyyyyyyyyyyyyyyyyyyyy thanks mister clive