I want to program "Option Byte" on STM8S005k6 without stvp. I do it by programming its code on Option Byte area but this makes it write protected only, not read protected:
void Read_Protect_Flash(void)
{
FLASH_SetProgrammingTime(FLASH_PROGRAMTIME_STANDARD);
// FLASH_SetProgrammingTime(FLASH_PROGRAMTIME_STANDARD);
while(FLASH_ReadOptionByte(0x4800) != 0xAA)
{
FLASH_Unlock(FLASH_MEMTYPE_DATA);
FLASH_EraseOptionByte(0x4800);
FLASH_ProgramOptionByte(0x4800, 0xAA);
FLASH_Lock(FLASH_MEMTYPE_DATA);
}
}
When I program it directly using IAR, it works. But when I program the functioning code on "PROGRAM MEMORY" area and the above code on "OPTION BYTE" area I just get write protection and not read protection. What should I do?
