cancel
Showing results for 
Search instead for 
Did you mean: 

Option Bytes Write Issue STM32L031K6

Hergen Blessen
Associate
Posted on February 07, 2018 at 10:24

Hello ,

i have trouble changing the Option Bytes BOR LEVEL in my project with a STM32L031K6T7  micro :

I am Using KEIL ARM V5 together with a PEMICRO CYCLONE UNIVERSAL Programming Device:

The Sequence i am using in my main init function is the following :

void OptionByteProg(uint8_t index, uint16_t data);

__INLINE __attribute__ ((section ('.ramcode'))) void OptionByteProg(uint8_t index, uint16_t data)

{

    FLASH->PEKEYR = 0x89ABCDEF;

    FLASH->PEKEYR = 0x02030405;

    FLASH->PRGKEYR = 0x8C9DAEBF;

    FLASH->PRGKEYR = 0x13141516;

    FLASH->OPTKEYR = 0xFBEAD9C8;

    FLASH->OPTKEYR = 0x24252627;

    /* ?16Bit???,?16Bit???,?????. */

    *(__IO uint32_t *)(OB_BASE + index * 4) = (uint32_t)((~data << 16) | data);

    while(FLASH->SR & FLASH_SR_BSY);

}

At Adressing the OB_BASE Setting the debugger is generating a hard fault. Why does this happen ?

OB_BASE is declared the following:

#define OB_BASE               ((uint32_t)0x1FF80000U)        /*!< FLASH Option Bytes base address */

Many thanks and greetings

0 REPLIES 0