cancel
Showing results for 
Search instead for 
Did you mean: 

Why Option bytes aren't written in running mode for STM8L ?

AMost
Associate

Dear All,

I am using STM8L ...

I had tried ST library functions to write option bytes but they aren't written.

the code as following :-

halt_opt_byte = FLASH_ReadByte(0x4808);

 if( halt_opt_byte != 0x02 )

 {

    FLASH_ProgramOptionByte(0x4808, 0x02);

 }

Still option byte is equal to Zero.

void FLASH_ProgramOptionByte(uint16_t Address, uint8_t Data)

{

 /* Check parameter */

 assert_param(IS_OPTION_BYTE_ADDRESS(Address));

 /* Enable write access to option bytes */

 FLASH->CR2 |= FLASH_CR2_OPT;

 /* Program option byte and his complement */

 *((PointerAttr uint8_t*)Address) = Data;

 FLASH_WaitForLastOperation(FLASH_MemType_Program);

 /* Disable write access to option bytes */

 FLASH->CR2 &= (uint8_t)(~FLASH_CR2_OPT);

}

Thanks a lot,

Ahmed

0 REPLIES 0