2018-02-20 11:07 PM
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.
2018-02-21 12:22 AM
Note that I do not use the EEPROM EOP interrupt.
2018-02-21 04:59 AM
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.
2018-02-21 05:34 AM
Duly noted, sir.
2018-02-21 06:08 AM
The EERPOM write routines are execute from RAM as I use the STM8S003 which can not execute EEPROM routines from Flash.
2018-02-21 12:14 PM
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.