AnsweredAssumed Answered

STM32F091 option bytes programming problem

Question asked by Rizzi.Gabriele on Feb 26, 2017
Latest reply on Mar 12, 2017 by Rizzi.Gabriele

Hi everybody,

I am facing a rather strange problem when trying to program the two user option bytes (0x1ffff804, 0x1ffff806).

The code I am using is rather straightforward:

    volatile FLASH_Status test3;

    volatile uint8_t test, test2;

    test = 0x12;

    test2=0;

 

    FLASH_Unlock();

    FLASH_OB_Unlock();

    test3 = FLASH_OB_ProgramData( 0x1FFFF804, test);

    FLASH_OB_Launch();

    FLASH_OB_Lock();

    FLASH_Lock();

    test2 = FLASH_OB_GetUser();

    

 

The code il flashed on a Nucleo64 board. Apparently the CPU hangs completely when executing FLASH_OB_Launch().

If I step the code through the instructions, it looks as if FLASH_OB_Launch() is generating a complete erase of the chip. In fact, I cannot simply reset and re-start execution, I need to re-load the program with the debugger.

If I remove FLASH_OB_Launch() the code executes with no problems, test3 reports FLASH_COMPLETE but the options bytes are not programmed.

 

I can read and program the option bytes without any problem using ST-link.

Elsewhere in the code I am erasing and programming the flash memory again with no problems, but the options bytes just do not program!

 

Can anybody please give me a hint?

 

Regards,

Gabriele

Outcomes