English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

1 answers

Use the fact that binary numbers wrap around so for example let 256 be 360 degrees. and then use a 256 entry lookup table to generate the values for the DAC.

Then you need a timer interrupt to give you a time basis. So for example with a 1/8000 time interrupt.

Changing the step_size will control the frequency.

unsigned char frq_cnt;

void timer_int( void)
{
frq_cnt += step_size;

DAC = sine_table_lookup( frq_cnt);
}

You can use larger frq_cnt for higher resolution and still use just the top 8 or 10 bits of the frq_cnt value so that the lookup table does not become ridiculously large.

2007-03-06 03:48:18 · answer #1 · answered by rscanner 6 · 0 0

fedest.com, questions and answers