I have a project with an arduino mega 2560 where I need two interupts:
an encoder sends out impulses when the value changes (it's a displacement measurement, sensitivity 1 pulse / 0,1 mm). Every time a pulse is sent, an integer (measurement variable) is added or subtracted.
an RTC clock to safe the value from the measurement variable to the memory
I've noticed that my program crashes after a while. I've set the second interupt to 10 ms. When I set it to 100 ms the program continuous much longer then at 10 ms.
Is it possible that there is some kind of conflict here that would crash the arduino?
UKHeliBob, yes I know the forum rules but I wanted to ask a general question and get a general answer to it. But if you really want I'll post the code in the next reply.
PeterH:
MathiasVDA:
Is it possible that there is some kind of conflict here that would crash the arduino?
A software bug is the more likely cause.
Thanks, now I know that I need to look more carefully over my code!
Ok after reading that excellent documentation from nightcrawler, I realize that I have approached the interupt thing from the wrong end. I want to do an encoder read and a safe to the RAM (using digitalWrite to SPI). I guess it might be better to set a flag in the interupt and safe the encoder reading to a temporary variable and later safe this in the RAM in the loop itself.
Does that sound reasonable? The loop can take more then the 10ms that I need the measurements of, but only when the readings are not required: during upload of the data by GSM.
I'll give this a try tomorrow (together with another library for the SRAM).
Thank Mr. Nick Gammon who put his precious time & effort to make that documentation. I used only the very basic parts of that tutorial to program a button, rising-falling edges etc. It helped me, thought it would help you as well.
Glad that you've found the probable solution.
Cheers...
Good ni8.