AnsweredAssumed Answered

BF548 - Wave Generator

Question asked by DarkLantern on Dec 14, 2009

Greetings everyone,

               I’m working with BF548 (school project) and I want to modify the Audio Loopback example project, to work as a wave generator (through the audio output). The main thing is that I don’t know which data type I should send to the output. I have created function for sine wave, and then I save its result in the array of u16 data type. When I send elements of this array to the audio output (in AD1980Callback function of the program) I can see some wave on the scope, but it is not a sine wave.

Could anyone please help me with that ?

These are my modifications of the AudioLoopback project:     


//Function: MakeSineWave. The function is called in the main.

void MakeSineWave(void) {

    int count ;

                double time_step = (2 * 3.14159) / (float) SAMPLE_DATA_SIZE;

                sample_time[0] = 0;

        for (count = 0; count < SAMPLE_DATA_SIZE; count++){

                sample_time[count] = sample_time[count-1] + time_step;

              sinewave[count] =  AMPLITUDE * sin(sample_time[count]);      //Array of  u16




//In the AD1980Callback function I have modified this:


/* copy the source (ADC) data to DAC channels */



#define PLAY_SINE 1



if (pointer > SAMPLE_DATA_SIZE)

{ pointer = 0;}

else pointer++;


// Send element of array to the both channels of the output.

  *(pDest+(NUM_DAC_CHANNELS*i))    = sinewave [pointer];                               

  *(pDest+1+(NUM_DAC_CHANNELS*i)) = sinewave [pointer];





More details are in attachement.

I use VisualDSP 5.0 with all updates.

Sorry for my English.
I’m from Czech Republic.


Thank you for any help.