cancel
Showing results for 
Search instead for 
Did you mean: 

CPU locks up sporadically after write to eeprom in STM8S003

de Vaal.Ruud
Associate III
Posted on February 21, 2018 at 08:07

On an STM8S003:

When I write a page to eeprom it sporadically seems to cause a lockup of the CPU. When I check with a scoop it seems to finish the writing but milliseconds thereafter a lockup happens. It does not help if I disable interrupts during the writing to eeprom. 

5 REPLIES 5
de Vaal.Ruud
Associate III
Posted on February 21, 2018 at 09:22

Note that I do not use the EEPROM EOP interrupt.  

Posted on February 21, 2018 at 13:59

If it is anything like the STM32, it just stuffs wait-states when you try to execute from FLASH while an erase/write is in progress, causing a complete stall of the system. Peripherals will keep clocking, but will overflow/underflow if real time needs are not serviced.

On the STM32 you avoid this by running code from RAM, or having a dual-bank flash.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on February 21, 2018 at 13:34

Duly noted, sir.

de Vaal.Ruud
Associate III
Posted on February 21, 2018 at 15:08

The EERPOM write routines are execute from RAM as I use the STM8S003 which can not execute EEPROM routines from Flash. 

de Vaal.Ruud
Associate III
Posted on February 21, 2018 at 21:14

I have solved the problem in an un-expected way. Initially I thought that other interrupts could lock the CPU while it was stalled and busy writing to the eeprom. So to verified this I disabled interrupts before the write to eeprom and enabled them after the write was finished. This did not help. What did help is that when I disabled individual interrupts like the ADC from happening during the write to eeprom and the problem was solved. I can not explain why.