.....comparison with my skills now
To use a lookup table is one of the easyest thing's in controller programming.
You make a table, the values could be precalculated in EXCEL.
Than the calculated Values e.g. for a sine would be taken into a variable.
unsigned char uc_sine[256]={0x00,0x01,...0xFF};
unsigned char uc_pointer=0;
Now when make a periodic reading with increments of a pointer from that table and put the Values to Your R2R Network, then occours there a sine Wave.
while(1)
{
PORTC=uc_sine[uc_pointer]; //Read out the actual Value for the R2R Network
uc_pointer++; //Increment Pointer to address the next value in table
delay_us(20); //Delay function to slow down the output frequency. Higher values give lower frequency
}
This little part of code is the whole generation loop!
The Problem is, when other tasks are running while outputting the wished wave, the output frequency will not be constant and the output waveform has dissortion.
So you had to make a function, that does not depend from the tasks in main loop.
To do that, You can write an interrupt function that interrupts the actual main loop to change to the next value in the table and put it out to R2R Network.
Timer Overflow or Timer Comparematch Interrupts are ideal for such a solution.
Try it out and put an Oscilloscope at the Output of the R2R Network. You would see there will occour a Wave.