My project has an important "compare" interrupt. The compare value is set by code in Loop(). There's a lot of variables in the Loop() code which makes the code inside the interrupt longer/shorter. Occasionally a combination of variables will cause the whole thing to seize up. Specifically: 1. Combination of variables set compare value to low number, but also activates code in if statements in interrupt code (i.e meaning it takes longer to process). 2. Interrupt gets stuck in a loop - i.e. as soon as code has processed it interrupts again 3. Code in Loop() either processes extremely slowly or stops altogether.
Are there any features of the Atmega328P that can help with this? If not, are there any standard good software practices for preventing this from happening? At the moment I'm just doing it by trial and error and it's all getting quite messy!
P.S. Atmega328P/Uno and 1.0.6 software.