Square Wave Signal Generator without using the PWM channels

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:

  1. 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)?
  2. Is it possible to do that without disturbing the PWM outputs, since I need to use 4-5 of them?
  3. Is it possible to add I2C to this without any problems?

you need to dive into timer interrupts and in direct port manipulation for the higher frequencies (see tutorial/playground section)

also related:

What you are asking isn't practical to do. Even using PWM pins, you can only get submultiples of the system clock frequency. I suggest you buy a cheap function generator module such as http://www.ebay.co.uk/itm/New-AD9850-DDS-Signal-Generator-Module-0-40MHz-Test-Equipment-/180820399452?_trksid=p4340.m1374&_trkparms=algo%3DPI.WATCH%26its%3DC%252BS%26itu%3DUCC%26otn%3D15%26ps%3D63%26clkid%3D9066588503326378681 and use the Arduino to control it.

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.

  1. 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.

Magician:

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.

  1. 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.

Thanks for all of the responses!