cancel
Showing results for 
Search instead for 
Did you mean: 

problem with FLASH_OB_ProgramData stm 32

TARHAN SAMAH
Senior
Posted on September 22, 2017 at 09:07

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

1 ACCEPTED SOLUTION

Accepted Solutions
Posted on September 22, 2017 at 20:35

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

5 REPLIES 5
Imen.D
ST Employee
Posted on September 22, 2017 at 14:20

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on September 22, 2017 at 20:18

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on September 22, 2017 at 20:35

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on October 12, 2017 at 08:24

thanks so muchhh

Posted on October 12, 2017 at 10:12

works perfectlyyyyyyyyyyyyyyyyyyyyy thanks mister clive