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.
baby breath
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment