Sunday, August 2, 2009

How to write C code to generate sine waves to TMS320C6711 DSP external DAC board?

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

No comments:

Post a Comment