Winner (or anybody) - Thanks for the code. I'm reasonable with electronics in general, but relatively new to microcontroller stuff, especially low-level programming.
Bottom line question: How do I incorporate the timer programming into more basic Arduino tasks. Can you give a generic example like "Place main loop here" and "Place time stuff here".
Specifically, I'll be writing a sketch to monitor an analog input (from a filtered audio source), and if the amplitude gets above a certain level, trigger an output - essentially looping through an analogRead the majority of the time. AnalogReads 5-10 times a second is sufficient, and exact consistency is not needed.
I need the adjustable square wave (at around 70 kHz, but will need to be adjustable from about 40 kHz to about 200-300 kHz with about 1 kHz resolution) to be the CLK for the switched-capacitor filter chip that is the filter for the audio input being read. So the timer has to be doing it's fast thing in the background, while the slow main program loops. The timer would only rarely have to be adjusted, which could be accomplished at compilation time, though it might be nice to be able to be readjusted in response to button presses during the main loop.
Can somebody please help me understand a generic outline of where the different parts go in the final Arduino sketch?
Thanks in advance.