So, I’ve been working on running a sequencer in my Yaeltex firmware, by tapping into the main loop and counting micros. It works pretty well, but I can hear a bit of clock jitter. Once I get save-to-EEPROM working, I noticed the clock slowed down for a second while writing. So I rewrote it to do a better job of catching up if it gets behind.
However, I finally noticed that my clock is just slow. It’s fairly consistent, with a little jitter, but something like 10% slow. I did some reading and I guess the micros() function is not based on a realtime clock but processor cycles? So if the arduino gets busy, it may lose track. Is that right?
So my question for you is: is there any way for me to build an internal clock that keeps reasonably accurate tempo? In timer.ino, the comments say it’s tied to an interrupt at a certain sample rate – can I tap into that? can I calculate the clock rate and count timer loops to know how much actual time has passed or something?