Skip to main content
Erenburg.Evgeny
Associate III
September 8, 2016
Question

Write u16 to EEPROM in STM8S003F3

  • September 8, 2016
  • 3 replies
  • 1222 views
Posted on September 08, 2016 at 13:22

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.

    This topic has been closed for replies.

    3 replies

    luca239955_stm1_st
    Associate
    September 8, 2016
    Posted on September 08, 2016 at 15:08

    what toolchain?

    For Cosmic just write

    @eeprom myEEpromVar;

    myEEpromVar = 10;

    and let the compiler (and libraries) do the work.

    Vima Amin
    Visitor II
    August 18, 2017
    Posted on August 18, 2017 at 03:47

    What  c and h file you include ?? And where to find them ?? I am using Cosmic compiler.

    Erenburg.Evgeny
    Associate III
    September 8, 2016
    Posted on September 08, 2016 at 15:58

    I work with IAR for STM8