In this example I am shifting the phase, it is working ok for 90 deg, for 180 deg there are distortions of sine wave.
The question - how to shift 180 deg withouth distortions ?
ard uses a delay(5), that's the main thing that takes time in the loop so this generates ~200 Hz, did that math in my head so check.
Remove the delay(5) and you'll see the max frequency this scheme can attain - slightly faster if you strip out the Serail.stuff. Toggle a LED in the loop() to see the frequency / 2 as a square wave. Obviously any work you do with the sine table values will slow you down, that is lower the frequency.
If you want predictable and constant frequencies it will take another scheme, interrupt driven timing would be one way.
The big win is stashing the sin values, then using offset indexing to get phase shifted values from one table. Nice with a power of two, automatic modular arithmetic!
Well I realize now that the frequency through the loop will mean the number of samples per second, so the sin wave you'd get from, say, an D/A conversion would be that frequency divided by the table size.
Google "edgar synth arduino" for a different way to use tables for waveform generation.