Hi all!
I m new to CCS. I am trying to implement FSK(v.21) modem a/c to d steps given in d tutorial at d following links:
I am giving my code for d part upto filtering here:
#include "tonecfg.h"
#include "dsk5510.h"
#include "dsk5510_aic23.h"
#include<stdio.h>
#include<math.h>
/* Codec configuration settings */
DSK5510_AIC23_Config config = {
0x0017, // 0 DSK5510_AIC23_LEFTINVOL Left line input channel volume
0x0017, // 1 DSK5510_AIC23_RIGHTINVOL Right line input channel volume
0x00FF, // 2 DSK5510_AIC23_LEFTHPVOL Left channel headphone volume
0x00FF, // 3 DSK5510_AIC23_RIGHTHPVOL Right channel headphone volume
0x0011, // 4 DSK5510_AIC23_ANAPATH Analog audio path control
0x0000, // 5 DSK5510_AIC23_DIGPATH Digital audio path control
0x0000, // 6 DSK5510_AIC23_POWERDOWN Power down control
0x0043, // 7 DSK5510_AIC23_DIGIF Digital audio Int16erface format
0x0081, // 8 DSK5510_AIC23_SAMPLERATE Sample rate control
0x0001 // 9 DSK5510_AIC23_DIGACT Digital Int16erface activation
};
#define FIRLEN 19
float coefs[FIRLEN] = {-0.008370237662365, 0.003523724616947, 0.01237363596323, 0.02713952454333, 0.04697784958127, 0.06994028726489, 0.09309959888495, 0.1130209563111, 0.1265124921103, 0.131279039604, 0.1265124921103, 0.1130209563111, 0.09309959888495, 0.06994028726489, 0.04697784958127, 0.02713952454333, 0.01237363596323, 0.003523724616947,-0.008370237662365};
//Int16 inputs[30] = {1.13128697433765 ,1.10984462553037 ,1.38344070298819 ,0.626150903279837 ,0.274450597351357 ,0.580994546781292 ,0.237492756839462 ,0.679663383970494 ,0.322571475796019 ,1.21779302841047 ,0.570692318798823 ,1.16763875860796 ,0.653554635345044 ,0.714598072144237 ,0.726021551753316 ,0.905479767550582 ,0.00435839319756108 ,0.479972769744528 ,0.113617074520466 ,1.09094320060140 ,1.12589149609019 ,0.521013993015299 ,0.763457292330922 ,0.108789020498579 ,0.920646227924225 ,1.15623623159461 ,0.0791557324943119 ,1.09534727278226 ,0.148991578063601 ,0.6170647215283747};
extern void circbuff(); // defined in asmfunctions.asm
float *inPtr; //poInt16er to input sample
float *outPtr; //poInt16er to output
float *coeff; //poInt16er to the coefficients
//Int16 leftsample, rightsample;
//Int16 input=0;
float output=0;
Int16 sample1;
Int16 j,i;
float mixerReal[120],mixerImg[120],mixer[120];
float mixerReal_param , mixerImg_param;
void filter_input(float*,float*,Int16);
void main()
{
DSK5510_AIC23_CodecHandle hCodec;
/* Initialize the board support library, must be called first */
DSK5510_init();
/* Start the codec */
hCodec = DSK5510_AIC23_openCodec(0, &config);
DSK5510_AIC23_setFreq(hCodec, DSK5510_AIC23_FREQ_16KHZ);
coeff = &coefs[0]; //coefs is coefficient of impulse response defined in fdacoefs_Int16.h
inPtr = &mixer[0]; //inPtr is a globally declared poInt16er to a Int16
//inPtr = &mixerReal[0];
outPtr = &output;
for ( j = 0; j < 120; j++ )
{
filter_input(&mixerReal_param,&mixerImg_param,j);
mixerReal[j]=mixerReal_param;
mixerImg[j]=mixerImg_param;
mixer[j]=mixerReal_param + mixerImg_param;
}
for(i=0;;i++)
{
for(sample1=0;sample1<120;sample1++)
{
//while (!DSK5510_AIC23_read16(hCodec, mixer[sample1]));
//while (!DSK5510_AIC23_read16(hCodec, mixer[sample1]));
circbuff();
}
while (!DSK5510_AIC23_write16(hCodec, output));
while (!DSK5510_AIC23_write16(hCodec, output));
}
DSK5510_AIC23_closeCodec(hCodec);
}
void filter_input(float*mixerReal_dummy,float*mixerImg_dummy,Int16 j_dummy)
{
float bitperiod = (1.0 / 300.0);
float fs = 9000, f1 = 1650, f0 = 1850, fc = 1750;
float temp = 0.0;
Int16 ii,jj,k=0;
float input[4]={1.0,0.0,1.0,0.0};
float modwave[120];
float Cos[ 4 ], Sin [ 4 ];
Int16 len = 0;
float sample[30];
for ( temp = (1/(fs+0.0)); temp <= bitperiod; temp += (1/(fs+0.0)) )
{
sample[len++] = ii;
}
////////////////////////////////////////////////////////////////////////////////////
////////////////*** Modulation ***//////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
//Int16 modwave[len * 4];
// Int16 j=0, jj;
for( ii = 0; ii < 4; ii++ ) {
if(input[ii]) {
for( jj = 0; jj < len; jj++ ) {
modwave[k++] = sin ( 2.0 * 3.1416 * (f1 + 0.0) * sample[jj] );
//prInt16f("%f ",modwave[j-1]);
}
} else {
for( jj = 0; jj < len; jj++ ) {
modwave[k++] = sin ( 2.0 * 3.1416 * (f0 + 0.0) * sample[jj] );
//prInt16f("%f ",modwave[j-1]);
}
}
}
////////////////////////////////////////////////////////////////////////////////////
////////////////*** Mixxing ***//////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
//Int16 Cos[ 4 ], Sin [ 4 ];
for ( jj = 0; jj < len; jj++ ) {
Cos[jj] = cos( 2.0 * 3.1416 * (fc+0.0) * sample[jj] );
Sin[jj] = sin( 2.0 * 3.1416 * (fc+0.0) * sample[jj] );
}
// Int16 mixerReal_dummy[len * 4], mixerImg_dummy[len * 4];
*mixerReal_dummy = modwave[j_dummy] * Cos[j_dummy%len];
*mixerImg_dummy = modwave[j_dummy] * Sin[j_dummy%len];
// return (*mixerReal_dummy,*mixerImg_dummy);
}
//ASM code for filtering:
.ARMS_off ;enable assembler for ARMS=0
.CPL_on ;enable assembler for CPL=1
.mmregs ;enable mem mapped register names
.global _circbuff
.global _inPtr ;global declarations
.global _outPtr
.global _coeff
; This is a skeleton project for initializing circular buffer
.data ;data section
;section where all the data is stored
FIR_len .set 12 ;length of the impulse response determines buffer space ex: 4 length filter
.align 16
firbuff .space 16*FIR_len ; allocating buffer space
oldindex .word 0 ; Allocate storage to save oldindex (defines where next sample
;has to be put in buffer)
.text ;this section contains the code
_circbuff ;function definition
MOV #FIR_len, BK03 ; Circular buffer size is 3 words
BSET AR1LC ; AR1 is configured to be modified circularly
;AMOV #010000h, XAR1 ; Circular buffer is in main data page 01
MOV #firbuff, BSA01 ; Circular buffer start address is 010A02h
;AMOV #_inPtr, XAR1 ; XAR1 == AR1H:AR1 && ARnH:(BSAxx + ARn)
MOV *(#oldindex), AR1 ; Index (in AR1) is 0000h
MOV dbl(*(#_inPtr)), XAR6
MOV dbl(*(#_outPtr)), XAR7
MOV dbl(*(#_coeff)), XAR2
MOV *AR6, *AR1+
MOV AR1, *(#oldindex)
; initialization done here
; processing starts below
MOV #0h, AC1
BCLR AR2LC ; XAR2 is linear buffer
RPT #11
MACM *AR1+, *AR2+, AC1
MOV HI(AC1), *AR7
; section 1: loading address
;ex:-
; MOV dbl(*(#_inPtr)), XAR6 ; XAR6 contains address to input
; check in help file and web link given in tutorial for syntax
; section 2: here set circular addressing for any ARn using the help file
; once set store the index of oldest state in this register
;ex:-
; MOV *AR6+, *ARn ; Receive input and store it in the location pointed by
; the circular buffer register
; Save the index of the oldest sample back into the location oldindex
RET
-------------XX---------------------
Can anybody sort out my problem?
Thanks in advance.
Suk