Error writing to data EEPROM using @eeprom
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-12-06 12:36 PM
Posted on December 06, 2013 at 21:36
I have a STM8S207 board and I'm using STVD version 4.3.3 with the Cosmic compiler. I am trying to use the @eeprom directive for writing/reading the data EEPROM and my system hangs when I try to write the data. Here's what I've been trying so far.
#include <string.h> #include ''stm8s.h'' #include ''stm8s_flash.h'' @eeprom s16 eeData; s16 localData; /* Read the data */ localData = eeData; // Works /* Write the data, scenario 1 */ eeData = localData; /* Write the data, scenario 2 */ eecpy(&eeData, &localData, 2); In both cases, the system hangs on the instruction in which I attempt to write to eeData. When stopping with the debugger I see that it is stopped inside function c_eewrw (library function?) at the following instruction: BTJF 0x505f, #2, 0xb155 Is there something else I need to do to get the system ready to write to data EEPROM? Thanks, Bryan
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
‎2013-12-08 11:25 PM
Posted on December 09, 2013 at 08:25
I work with STM8L, but it is probably equivalent.
I have to unlock the eeprom before writing it, but on 8L writing to a protected memory don't hang the CPU.Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-12-09 2:45 AM
Posted on December 09, 2013 at 11:45
Bryan,
the instruction where your program hangs waits for the EEPROM programming end. As Argail told you, if you don't unlock EEPROM by writing the sequence: 0xAE 0x56 in FLASH_DUKR, your code will wait forever. Regards, EtaPhiOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-12-09 10:52 AM
Posted on December 09, 2013 at 19:52
All,
Thanks for the help. Turns out I was doing a few things wrong. First, I had a typo in my call to _fctcpy, so the flash programming routines of mine were not loaded into RAM. Then, as mentioned, I had also forgotten to unlock EEPROM. Also, I am using an external osciallator that operates above 16 MHz, so I set OPT7 to add a wait state as suggested by the datasheet. I also discovered that the data EEPROM gets cleared upon loading the program with the debugger. Makes sense, but I thought the debugger just re-wrote program flash, not the data EEPROM. Just restarting the debugger without stopping/starting the debugger does not re-write data EEPROM. Once I got all that straight I was able to write to data EEPROM and see my data still there upon a power cycle. Thanks, Bryan