I'm using the STM8S003 and I've to change the default value of the option byte AFR0. This operation is easy using a programmer but I'd like to insert this procedure in the source code. Is it possible? Some examples ? Thanks,
Hi everyone,
I'm using the STM8S003 and I need to use the alternate function of PC5 so I've to change the default value of the option byte AFR0.
This operation is easy using a programmer (ex. STVP) but I'd like to insert this procedure in the source code. I've created this small routine for doing it:
if(FLASH_ReadOptionByte(0x4803)!=0x01)
{
FLASH_Unlock(FLASH_MEMTYPE_DATA);
FLASH_EraseOptionByte (0x4803);
FLASH_ProgramOptionByte(0x4803, 0x01);
FLASH_Lock(FLASH_MEMTYPE_DATA);
}
It seems to work correctly but I'd like to have your opinion about it.
Thanks,
Alan
