DSPRelated.com
Forums

Sound quality with and without MCBSP

Started by asim...@yahoo.de January 18, 2012
Hi everyone,

I am a newbie in DSP programming and started to get experience with a DSK6713. I programmed a simple code that generates a sinus tone by
1)using the MCBSP for sending data or 2)just using the AIC23 Codec functions. I realized that in the first case the sound quality is worse than in the second case. I wonder why cuz in the first case the MCBSP uses the SAME codec or am I missunderstanding something. Anyway, here is the code:

#define CHIP_6713

#include
#include

#include "dsk6713_aic23.h"
#include "dsk6713_dip.h"
#include "dsk6713_led.h"
#include "dsk6713.h"

#define LOOPLENGTH 8

DSK6713_AIC23_Config aic23config = DSK6713_AIC23_DEFAULTCONFIG;
MCBSP_Config mcbspConfig = { 0x00010000, // SPCR is set for transmitting
0x00000000,
0x000000A0, // 1-phase 32bit word for XCR
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
};

short loopIdx, gain = 5;
int sineTable[ LOOPLENGTH ] = { 0, 707, 1000, 707, 0, -707, -1000, -707 };

void main(void) {

DSK6713_init();
DSK6713_LED_init();
DSK6713_DIP_init();

DSK6713_AIC23_CodecHandle hCodec;
hCodec = DSK6713_AIC23_openCodec( 0, &aic23config );
DSK6713_AIC23_setFreq( hCodec, DSK6713_AIC23_FREQ_8KHZ );
extern far MCBSP_Handle DSK6713_AIC23_DATAHANDLE;
MCBSP_config( DSK6713_AIC23_DATAHANDLE, &mcbspConfig );
MCBSP_start( DSK6713_AIC23_DATAHANDLE, MCBSP_XMIT_START |
MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC , 220 );

while( 1 ) {

if ( DSK6713_DIP_get( 0 ) == 0 ) {

DSK6713_LED_on( 0 );

while( MCBSP_xrdy( DSK6713_AIC23_DATAHANDLE ) )

// while( !DSK6713_AIC23_write( hCodec, sineTable[ loopIdx ] ) );
MCBSP_write( DSK6713_AIC23_DATAHANDLE, sineTable[ loopIdx ] );

if ( ++loopIdx == LOOPLENGTH) loopIdx = 0;

} else

DSK6713_LED_off( 0 );

}

}

_____________________________________
Asim-

It looks to me like the way you've written your C code, it will not write to Tx if
it's not ready (good), skip the current value completely in that case and go to the
next value (not good), and possibly write some values more than once if it takes Tx a
bit of time to become not ready after a write (also not good).

Suggest to try this:

while (!MCBSP_xrdy(DSK6713_AIC23_DATAHANDLE)); /* wait for Tx to be read */
MCBSP_write(DSK6713_AIC23_DATAHANDLE, sineTable[loopIdx]); /* write 1 sample */

Also, assuming the codec setting is for 16-bit words, and since you have declared
sineTable as int, suggest to check to make sure that passing an int to McBSP_write()
is Ok.

-Jeff

a...@yahoo.de wrote:
>
> Hi everyone,
>
> I am a newbie in DSP programming and started to get experience with a DSK6713. I programmed a simple code that generates a sinus tone by
> 1)using the MCBSP for sending data or 2)just using the AIC23 Codec functions. I realized that in the first case the sound quality is worse than in the second case. I wonder why cuz in the first case the MCBSP uses the SAME codec or am I missunderstanding something. Anyway, here is the code:
>
> #define CHIP_6713
>
> #include
> #include #include "dsk6713_aic23.h"
> #include "dsk6713_dip.h"
> #include "dsk6713_led.h"
> #include "dsk6713.h"
>
> #define LOOPLENGTH 8
>
> DSK6713_AIC23_Config aic23config = DSK6713_AIC23_DEFAULTCONFIG;
> MCBSP_Config mcbspConfig = { 0x00010000, // SPCR is set for transmitting
> 0x00000000,
> 0x000000A0, // 1-phase 32bit word for XCR
> 0x00000000,
> 0x00000000,
> 0x00000000,
> 0x00000000,
> 0x00000000,
> };
>
> short loopIdx, gain = 5;
> int sineTable[ LOOPLENGTH ] = { 0, 707, 1000, 707, 0, -707, -1000, -707 };
>
> void main(void) {
>
> DSK6713_init();
> DSK6713_LED_init();
> DSK6713_DIP_init();
>
> DSK6713_AIC23_CodecHandle hCodec;
> hCodec = DSK6713_AIC23_openCodec( 0, &aic23config );
> DSK6713_AIC23_setFreq( hCodec, DSK6713_AIC23_FREQ_8KHZ );
>
> extern far MCBSP_Handle DSK6713_AIC23_DATAHANDLE;
> MCBSP_config( DSK6713_AIC23_DATAHANDLE, &mcbspConfig );
> MCBSP_start( DSK6713_AIC23_DATAHANDLE, MCBSP_XMIT_START |
> MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC , 220 );
>
> while( 1 ) {
>
> if ( DSK6713_DIP_get( 0 ) == 0 ) {
>
> DSK6713_LED_on( 0 );
>
> while( MCBSP_xrdy( DSK6713_AIC23_DATAHANDLE ) )
>
> // while( !DSK6713_AIC23_write( hCodec, sineTable[ loopIdx ] ) );
> MCBSP_write( DSK6713_AIC23_DATAHANDLE, sineTable[ loopIdx ] );
>
> if ( ++loopIdx == LOOPLENGTH) loopIdx = 0;
>
> } else
>
> DSK6713_LED_off( 0 );
>
> }
>
> }

_____________________________________
Hi Jeff,

thank you for your answer. I clearly understand what you mean. I might have read the function description for MCBSP_xready wrong:) cuz I wanted the MCBSP to do: write data when you are ready but exactly the opposite was done.

Burak

Hi everyone,
>
>I am a newbie in DSP programming and started to get experience with a DSK6713. I programmed a simple code that generates a sinus tone by
>1)using the MCBSP for sending data or 2)just using the AIC23 Codec functions. I realized that in the first case the sound quality is worse than in the second case. I wonder why cuz in the first case the MCBSP uses the SAME codec or am I missunderstanding something. Anyway, here is the code:
>
>#define CHIP_6713
>
>#include
>#include
>
>#include "dsk6713_aic23.h"
>#include "dsk6713_dip.h"
>#include "dsk6713_led.h"
>#include "dsk6713.h"
>
>#define LOOPLENGTH 8
>
>DSK6713_AIC23_Config aic23config = DSK6713_AIC23_DEFAULTCONFIG;
>MCBSP_Config mcbspConfig = { 0x00010000, // SPCR is set for transmitting
> 0x00000000,
> 0x000000A0, // 1-phase 32bit word for XCR
> 0x00000000,
> 0x00000000,
> 0x00000000,
> 0x00000000,
> 0x00000000,
>};
>
>short loopIdx, gain = 5;
>int sineTable[ LOOPLENGTH ] = { 0, 707, 1000, 707, 0, -707, -1000, -707 };
>
>void main(void) {
>
> DSK6713_init();
> DSK6713_LED_init();
> DSK6713_DIP_init();
>
> DSK6713_AIC23_CodecHandle hCodec;
> hCodec = DSK6713_AIC23_openCodec( 0, &aic23config );
> DSK6713_AIC23_setFreq( hCodec, DSK6713_AIC23_FREQ_8KHZ );
> extern far MCBSP_Handle DSK6713_AIC23_DATAHANDLE;
> MCBSP_config( DSK6713_AIC23_DATAHANDLE, &mcbspConfig );
> MCBSP_start( DSK6713_AIC23_DATAHANDLE, MCBSP_XMIT_START |
> MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC , 220 );
>
> while( 1 ) {
>
> if ( DSK6713_DIP_get( 0 ) == 0 ) {
>
> DSK6713_LED_on( 0 );
>
> while( MCBSP_xrdy( DSK6713_AIC23_DATAHANDLE ) )
>
>// while( !DSK6713_AIC23_write( hCodec, sineTable[ loopIdx ] ) );
> MCBSP_write( DSK6713_AIC23_DATAHANDLE, sineTable[ loopIdx ] );
>
> if ( ++loopIdx == LOOPLENGTH) loopIdx = 0;
>
> } else
>
> DSK6713_LED_off( 0 );
>
> }
>
>}
>
>_____________________________________

_____________________________________
Asim-

> thank you for your answer. I clearly understand what
> you mean. I might have read the function description for
> MCBSP_xready wrong:) cuz I wanted the MCBSP to do: write
> data when you are ready but exactly the opposite was done.

Ok sounds good. One comment... please answer each post in sequence; don't go back and forward the original post. It
makes it easier for people to follow, especially when searching through the forum some time from now.

-Jeff

> Hi everyone,
>>
>>I am a newbie in DSP programming and started to get experience with a DSK6713. I programmed a simple code that
>> generates a sinus tone by
>>1)using the MCBSP for sending data or 2)just using the AIC23 Codec functions. I realized that in the first case the
>> sound quality is worse than in the second case. I wonder why cuz in the first case the MCBSP uses the SAME codec or
>> am I missunderstanding something. Anyway, here is the code:
>>
>>#define CHIP_6713
>>
>>#include
>>#include
>>
>>#include "dsk6713_aic23.h"
>>#include "dsk6713_dip.h"
>>#include "dsk6713_led.h"
>>#include "dsk6713.h"
>>
>>#define LOOPLENGTH 8
>>
>>DSK6713_AIC23_Config aic23config = DSK6713_AIC23_DEFAULTCONFIG;
>>MCBSP_Config mcbspConfig = { 0x00010000, // SPCR is set for transmitting
>> 0x00000000,
>> 0x000000A0, // 1-phase 32bit word for XCR
>> 0x00000000,
>> 0x00000000,
>> 0x00000000,
>> 0x00000000,
>> 0x00000000,
>>};
>>
>>short loopIdx, gain = 5;
>>int sineTable[ LOOPLENGTH ] = { 0, 707, 1000, 707, 0, -707, -1000, -707 };
>>
>>void main(void) {
>>
>> DSK6713_init();
>> DSK6713_LED_init();
>> DSK6713_DIP_init();
>>
>> DSK6713_AIC23_CodecHandle hCodec;
>> hCodec = DSK6713_AIC23_openCodec( 0, &aic23config );
>> DSK6713_AIC23_setFreq( hCodec, DSK6713_AIC23_FREQ_8KHZ );
>> extern far MCBSP_Handle DSK6713_AIC23_DATAHANDLE;
>> MCBSP_config( DSK6713_AIC23_DATAHANDLE, &mcbspConfig );
>> MCBSP_start( DSK6713_AIC23_DATAHANDLE, MCBSP_XMIT_START |
>> MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC , 220 );
>>
>> while( 1 ) {
>>
>> if ( DSK6713_DIP_get( 0 ) == 0 ) {
>>
>> DSK6713_LED_on( 0 );
>>
>> while( MCBSP_xrdy( DSK6713_AIC23_DATAHANDLE ) )
>>
>>// while( !DSK6713_AIC23_write( hCodec, sineTable[ loopIdx ] ) );
>> MCBSP_write( DSK6713_AIC23_DATAHANDLE, sineTable[ loopIdx ] );
>>
>> if ( ++loopIdx == LOOPLENGTH) loopIdx = 0;
>>
>> } else
>>
>> DSK6713_LED_off( 0 );
>>
>> }
>>
>>}

_____________________________________