Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 4924

DDS generating variable frequency(1Hz - 20kHz) sinewave using DAC

$
0
0
Hey. I need to generate a variable frequency sinewave using DAC. I have implement sine wave look up table and phase accumulator:

Code (C):
  1.  
  2.  
  3. void SINE_LOOKUP_TABLE(){
  4.  
  5. const int BUFF_SIZE = 4096;  // size of output buffer (samples)
  6. const int Fs = 32.768;       // sample rate (Hz)
  7. const int LUT_SIZE = 1024;  // lookup table size
  8.  
  9. int16_t LUT[LUT_SIZE];      // our sine wave LUT
  10.  
  11. for (int i = 0; i < LUT_SIZE; ++i)
  12. {
  13.     LUT[i] = (int16_t)sinf(((float)i *360)/1024) *2047;
  14. }...
DDS generating variable frequency(1Hz - 20kHz) sinewave using DAC

Viewing all articles
Browse latest Browse all 4924

Trending Articles