Write u16 to EEPROM in STM8S003F3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-09-08 4:22 AM
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 discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-09-08 6:08 AM
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.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-09-08 6:58 AM
Posted on September 08, 2016 at 15:58
I work with IAR for STM8
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-08-17 8:47 PM
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.
