I'm pretty sure this is feasible, but I am unsure the best way to approach this.
I'd like to use an Arduino to fairly quickly implement a precise single square wave signal generator for a frequency controlled device, that will range from 100kHz to 200kHz within a precision of 100Hz or better with 50% duty cycle. I also want to use the PWMs as DAC outputs, so I would like to avoid using those channels if possible, unless I absolutely have to (I can spare one of them).
The other part of this is I want the signal generator and DACs to be non-blocking (I believe this is the terminology, once it starts it keeps going without significant interaction with the system), and controllable through I2C (which I know is an option). I have done some Atmel programming so I know that some of the atmels can do this (something similar to the AWEX functionality in the 128A1), though I am unsure if the atmega328 will.
So in brief my questions are:
How should I go about creating a 100kHz-200kHz within +/- 100Hz square wave signal that is not disturbed by occasionally doing other functions on the chip (such as changing the PWM outputs for DAC control, EEPROM read and writes, maybe minor ADC processing), but be able to change it fairly quickly (As fast as I2C would let me)?
Is it possible to do that without disturbing the PWM outputs, since I need to use 4-5 of them?
Is it possible to add I2C to this without any problems?
How should I go about creating a 100kHz-200kHz within +/- 100Hz square wave signal
Probably not with precision you need. I think if timer will run in fast PWM and no prescaler, to get 100 kHz from 16 MHz clock divisor is 160, than next "step" divisor 159, would produce 100.628930818 kHz. Or +628Hz.
Is it possible to do that without disturbing the PWM outputs, since I need to use 4-5 of them?
No, the only way to do this, is using PWM channel, assigning one Timer for this. Depends on board you have, it would left 4 or more PWM outputs.
How should I go about creating a 100kHz-200kHz within +/- 100Hz square wave signal
Probably not with precision you need. I think if timer will run in fast PWM and no prescaler, to get 100 kHz from 16 MHz clock divisor is 160, than next "step" divisor 159, would produce 100.628930818 kHz. Or +628Hz.
Is it possible to do that without disturbing the PWM outputs, since I need to use 4-5 of them?
No, the only way to do this, is using PWM channel, assigning one Timer for this. Depends on board you have, it would left 4 or more PWM outputs.
This may work. I'll check to see if this will work and give it a shot.