DSPRelated.com
Forums

incorrect signal output using codec

Started by czarlee November 14, 2002
Hi ,
I'm sorry if someone has already asked this question.
I'm having a problem using the codec program. I want
to do a simple function of outputting a cosine with
frequency component of 1000Hz. The problem is when I
monitor the signal using oscilloscope , the waveform
doesn't even look like a sinusoid.
I'm sure somebody else has encountered this problem
before, please tell me what is wrong.
Here is my simple code. Thanking you in advance.

#include <type.h>
#include <board.h>
#include <codec.h>
#include <mcbsp54.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <std.h>
#include <dsplib.h>
#include <tms320.h>

#define PI 3.14159265

HANDLE hHandset;

int out1=0;

void main()
{
int i;
int out2=0;

float sin_value2[16]={0};
short fmtQ15[16]={0};

for(i=0;i<16;i++){
sin_value2[i]=cos(2*PI*1000*i*1/8000);
}
hHandset = codec_open(HANDSET_CODEC);

codec_dac_mode(hHandset, CODEC_DAC_15BIT);

codec_adc_mode(hHandset, CODEC_ADC_15BIT);

codec_ain_gain(hHandset, CODEC_AIN_0dB);

codec_aout_gain(hHandset, CODEC_AOUT_MINUS_0dB);

codec_sample_rate(hHandset,SR_8000); for(out1=0;out1<10000;out1++){
fltoq15(sin_value2,fmtQ15,16);
for(out2=0;out2<16;out2++){
*(volatile u16*)DXR1_ADDR(HANDSET_CODEC)=fmtQ15[out2];
}
}
return;
} li
UTM
Malaysia