Skip to main content
TARHAN SAMAH
Senior
September 22, 2017
Solved

problem with FLASH_OB_ProgramData stm 32

  • September 22, 2017
  • 5 replies
  • 1235 views
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

    This topic has been closed for replies.
    Best answer by Tesla DeLorean
    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.

    5 replies

    ST Technical Moderator
    September 22, 2017
    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

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Tesla DeLorean
    Guru
    September 22, 2017
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Tesla DeLoreanBest answer
    Guru
    September 22, 2017
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    TARHAN SAMAH
    Senior
    October 12, 2017
    Posted on October 12, 2017 at 08:24

    thanks so muchhh