EEPROM write when using timer interrupts

Tried digging around for this, hoping someone has some insight.

So I have program that runs stepper motors via timer interrupts... every X uS a step pulse is generated.

I also have the standard main "loop" for polling pins etc... i.e. not terribly time critical functions.

One the things I do in the "loop" is I keep a runtime counter, so I can keep track of how long the arduino has been running - I basically tickup a counter in non-volatile memory via a EEPROM write every 15 minutes.

Obviously, it's critical that the timer interrupts fire on time to step the motor or I will have missed steps, stalls etc...

Question is, from what I read, the EEPROM writes take a long time (in the context of motor timing :slight_smile: ) to complete.... like ~5ms.

Will my timer interrupts still fire while this EEPROM write is taking place? Can the write be "interrupted" by my timer ISR? i.e. my motor can be running as fast as 130 uS pulse timing, last thing I want is for everything to stop for ~5ms while that write is occuring.

The eeprom writes involve an interrupt EE_READY_vect. It is of lower priority than the timer interrupts.

I think that the eeprom ready interrupt will block the timer interrupt, but this is best resolved with an oscilloscope.

More googling has revealed that it's maybe not an issue, as the EEPROM writing is handled by hardware. So if the timer interrupt fires, the write will ultimately complete.

I don't know if it's true but a guy said in this thread:

https://www.avrfreaks.net/forum/should-interrupts-be-disabled-during-eeprom-update

"There is no danger of an EEPROM write failing due to being interrupted by an ISR. Once initiated, the EEPROM write is handled in hardware. As a matter of fact (although this isn't relevant to your case), an EEPROM write will continue to successful completion even if the AVR goes into reset before the the write is complete, as long as VCC is high enough."

That's fine and dandy but if the write operation disables interrupts then the write will complete but my timer interrupt will be ignored (if I am understand all of this).

I'll try looking at the Atmel datasheet again and see if I can make anymore sense of it.