Algorithm for fast waveform generation w/ amplitude control

The speed (frequency) the waveform is output at can be varied by changing the timer speed or delay loop value

Or you can use a fixed frequency and a phase accumulator.