AnsweredAssumed Answered

Write u16 to EEPROM in STM8S003F3

Question asked by erenburg.evgeny.002 on Sep 8, 2016
Latest reply on Aug 18, 2017 by Vima Amin

What is the right procedure to write to EEPROM?

I saw the following code:

oid CEEPROM::UNLOCK_EEPROM_IF_LOCKED()         
{                                          
    if ( EEPROM_IS_WRITE_PROTECTED() )
    {      
        FLASH_DUKR = 0xAE;                 
        FLASH_DUKR = 0x56;                 
        while (EEPROM_IS_WRITE_PROTECTED());
    }                                      
}
 
void CEEPROM::LOCK_EEPROM()                    
{
    FLASH_IAPSR_DUL = 0;   
    while( !EEPROM_IS_WRITE_PROTECTED() ); 
  }
 
void CEEPROM::Write(unsigned short address, unsigned char data)
{
    UNLOCK_EEPROM_IF_LOCKED();
    *(unsigned char*)(address) = data;
    LOCK_EEPROM();
}

but I doubt it.

Outcomes