Forums

sampling with 6713DSK

Started by pascal May 26, 2009
hi every body,
i am using 6713DSK for my project.i use AIC23 for sampling a 1khz sin wave
and collect them in a buffer.i configured MCBSP for 32 bit one frame
format.after sampling i shift 32 bits samples to right to just have 16 bits
of left channel.then when i plot the collected samples in CCS it is not a
1khz sin wave.does anyone know what is my problem. i dont have mush
time.please help me if you can.also you can send your response to this mail
address:mahnaznamazi@gmail.com
thanks.
mahnaz.  

my code: 
//connect a 1khx sin wave to channel left of codec ,
//then plot the buffer sample[8] in ccs,it must be a 1khx sin wave.

#define CHIP_6713

#include <stdio.h>

#include <csl.h>
#include <csl_mcbsp.h>

#include "dsk6713.h"
#include "dsk6713_aic23.h"

/* Codec configuration settings */
DSK6713_AIC23_Config config = {
    0x0017, // 0 DSK6713_AIC23_LEFTINVOL  Left line input channel volume
    0x0017, // 1 DSK6713_AIC23_RIGHTINVOL Right line input channel volume
    0x00d8, // 2 DSK6713_AIC23_LEFTHPVOL  Left channel headphone volume
    0x00d8, // 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone volume
    0x0011, // 4 DSK6713_AIC23_ANAPATH    Analog audio path control
    0x0000, // 5 DSK6713_AIC23_DIGPATH    Digital audio path control
    0x0000, // 6 DSK6713_AIC23_POWERDOWN  Power down control
    0x0043, // 7 DSK6713_AIC23_DIGIF      Digital audio interface format
    0x0029, // 8 DSK6713_AIC23_SAMPLERATE Sample rate control
    0x0001  // 9 DSK6713_AIC23_DIGACT     Digital interface activation
};

Uint32 sample[64];
int i;
void init_mcbsp(void);
void main()
{
    DSK6713_AIC23_CodecHandle hCodec;

    CSL_init();
    init_mcbsp();
    DSK6713_init();

 /* Start the codec */
    hCodec = DSK6713_AIC23_openCodec(0, &config);

for (i=0;i<64;i++)
{
/* Read a 16-bit value from the left channel */
DSK6713_AIC23_read(hCodec, &sample[i]);
//sample[i]=(sample[i])>>16;
printf("sample %d=%d\n",i+1,sample[i]);
}

 DSK6713_AIC23_closeCodec(hCodec);

} //end of main
//-----------------------------

void init_mcbsp(){
MCBSP_Config  mcbsp_config= {
        MCBSP_FMKS(SPCR, FREE, NO)              |
        MCBSP_FMKS(SPCR, SOFT, NO)              |
        MCBSP_FMKS(SPCR, FRST, YES)             |
        MCBSP_FMKS(SPCR, GRST, YES)             |
        MCBSP_FMKS(SPCR, XINTM, XRDY)           |
        MCBSP_FMKS(SPCR, XSYNCERR, NO)          |
        MCBSP_FMKS(SPCR, XRST, YES)             |
        MCBSP_FMKS(SPCR, DLB, OFF)              |
        MCBSP_FMKS(SPCR, RJUST, RZF)            |
        MCBSP_FMKS(SPCR, CLKSTP, DISABLE)       |
        MCBSP_FMKS(SPCR, DXENA, OFF)            |
        MCBSP_FMKS(SPCR, RINTM, RRDY)           |
        MCBSP_FMKS(SPCR, RSYNCERR, NO)          |
        MCBSP_FMKS(SPCR, RRST, YES),

        MCBSP_FMKS(RCR, RPHASE, SINGLE)         |
        MCBSP_FMKS(RCR, RFRLEN2, DEFAULT)       |
        MCBSP_FMKS(RCR, RWDLEN2, DEFAULT)       |
        MCBSP_FMKS(RCR, RCOMPAND, MSB)          |
        MCBSP_FMKS(RCR, RFIG, NO)               |
        MCBSP_FMKS(RCR, RDATDLY, 0BIT)          |
        MCBSP_FMKS(RCR, RFRLEN1, OF(0))         | // This changes to 1
FRAME
        MCBSP_FMKS(RCR, RWDLEN1, 32BIT)         | // This changes to 16
bits per frame
        MCBSP_FMKS(RCR, RWDREVRS, DISABLE),

        MCBSP_FMKS(XCR, XPHASE, SINGLE)         |
        MCBSP_FMKS(XCR, XFRLEN2, DEFAULT)       |
        MCBSP_FMKS(XCR, XWDLEN2, DEFAULT)       |
        MCBSP_FMKS(XCR, XCOMPAND, MSB)          |
        MCBSP_FMKS(XCR, XFIG, NO)               |
        MCBSP_FMKS(XCR, XDATDLY, 0BIT)          |
        MCBSP_FMKS(XCR, XFRLEN1, OF(0))         | // This changes to 1
FRAME
        MCBSP_FMKS(XCR, XWDLEN1, 32BIT)         | // This changes to 16
bits per frame
        MCBSP_FMKS(XCR, XWDREVRS, DISABLE),
        
        MCBSP_FMKS(SRGR, GSYNC, DEFAULT)        |
        MCBSP_FMKS(SRGR, CLKSP, DEFAULT)        |
        MCBSP_FMKS(SRGR, CLKSM, DEFAULT)        |
        MCBSP_FMKS(SRGR, FSGM, DEFAULT)         |
        MCBSP_FMKS(SRGR, FPER, DEFAULT)         |
        MCBSP_FMKS(SRGR, FWID, DEFAULT)         |
        MCBSP_FMKS(SRGR, CLKGDV, DEFAULT),

        MCBSP_MCR_DEFAULT,
        MCBSP_RCER_DEFAULT,
        MCBSP_XCER_DEFAULT,

        MCBSP_FMKS(PCR, XIOEN, SP)              |
        MCBSP_FMKS(PCR, RIOEN, SP)              |
        MCBSP_FMKS(PCR, FSXM, EXTERNAL)         |
        MCBSP_FMKS(PCR, FSRM, EXTERNAL)         |
        MCBSP_FMKS(PCR, CLKXM, INPUT)           |
        MCBSP_FMKS(PCR, CLKRM, INPUT)           |
        MCBSP_FMKS(PCR, CLKSSTAT, DEFAULT)      |
        MCBSP_FMKS(PCR, DXSTAT, DEFAULT)        |
        MCBSP_FMKS(PCR, FSXP, ACTIVEHIGH)       |
        MCBSP_FMKS(PCR, FSRP, ACTIVEHIGH)       |
        MCBSP_FMKS(PCR, CLKXP, FALLING)         |
        MCBSP_FMKS(PCR, CLKRP, RISING)
    };
MCBSP_Handle hMcbsp;

hMcbsp = MCBSP_open(MCBSP_DEV1,MCBSP_OPEN_RESET);
if (hMcbsp==INV){
 printf("can not open mcbsp1\n");
 }
MCBSP_config(hMcbsp,&mcbsp_config);
MCBSP_start( hMcbsp, MCBSP_RCV_START | MCBSP_SRGR_START |
MCBSP_SRGR_FRAMESYNC ,220);

}