Skip to main content
Visitor II
February 21, 2018
Question

CPU locks up sporadically after write to eeprom in STM8S003

  • February 21, 2018
  • 4 replies
  • 1186 views
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. 

    This topic has been closed for replies.

    4 replies

    February 21, 2018
    Posted on February 21, 2018 at 09:22

    Note that I do not use the EEPROM EOP interrupt.  

    Visitor II
    February 21, 2018
    Posted on February 21, 2018 at 13:34

    Duly noted, sir.

    Graduate II
    February 21, 2018
    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.

    February 21, 2018
    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. 

    February 21, 2018
    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.