This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

what is wrong with my code?



i am using following code with DSK6713

#include "dsk6713_aic23.h" //codec support

Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate

#define DSK6713_AIC23_INPUT_MIC 0x0015

#define DSK6713_AIC23_INPUT_LINE 0x0011

Uint16 inputsource=DSK6713_AIC23_INPUT_MIC; //select input

#define N 2400000 //buffer size 300 secs

long i;

short buffer[N];

#pragma DATA_SECTION(buffer,".EXT_RAM") //buffer in ext memory

void main()

{

short recording = 0;

short playing = 0;

for (i=0 ; i<N ; i++) buffer[i] = 0;

DSK6713_DIP_init();

DSK6713_LED_init();

comm_poll(); //init DSK, codec

while(1) //infinite loop

{

if(DSK6713_DIP_get(3) == 0) //if SW#3 is pressed

{

i=0;

recording = 1; //start recording

while (recording == 1)

{

DSK6713_LED_on(3); //turn on LED#3

buffer[i++] = input_left_sample(); //input data

if (i>2000)

if (DSK6713_DIP_get(3)==1) //if SW#3 lifted

{

recording = 0; //stop recording

DSK6713_LED_off(3); //turn LED#3 off

}

}

}

if(DSK6713_DIP_get(0)==0) //if SW#0 is pressed

{

i=0;

playing = 1; //start playing

while (playing == 1)

{

DSK6713_LED_on(0); //turn on LED#0

output_left_sample(buffer[i++]); //output data

if (i>2000)

if (DSK6713_DIP_get(0) == 1) //if SW#1 is lifted

{

playing = 0; //stop playing

DSK6713_LED_off(0); //turn LED#0 off

}

}

}

}

}

this code records speech from mic when DIP 3 is kept pushed and LED 3 is on, stores it in memory and plays it back when DIP 0 is pressed down.

I have included all the support files and build program successfully. Even .out file is generated. But after loading and running program, when I press DIP 3, LED glows and when I release it LED is still on. And nothing happens further, LED remains on.

Is there something wrong with program? it is from standard text book. Can this be due to faulty mic? program just keep running and no error is shown...

Please it is urgent. Thanks in advance

  • Hi,

    Are you trying this experiment with emulator?

    Have you try to pause the CCS debugging code while running the code?

    Try to debug your code through "step over" & "step into" options

    Try to add some system prints in code to understand/know that where you are.

  • thanks for reply...

    why do i need emulator? as i have said this code is from standard textbook and i have followed same procedure as in the book. And this code is also very straight forward so I dont think there is any problem with the code.

    code compiles without error and also runs but it gets stuck. when I realese DIP after recording, LED should turn off, but it doesn't. It means that recording is not done or audio is not getting into DSP, am I right?

    Is thereany way to see audio has been recorded or not?

    Please help me...

    Thanks again.

  • Hi,

    If you have emulator then debugging is very easy.

    code compiles without error and also runs but it gets stuck. when I realese DIP after recording, LED should turn off, but it doesn't. It means that recording is not done or audio is not getting into DSP, am I right?

    I'm suspecting that your code doesn't waiting for key releasing,

    Tr this  modified code,

    void main()

    {

    short recording = 0;

    short playing = 0;

    for (i=0 ; i<N ; i++)
    buffer[i] = 0;

    DSK6713_DIP_init();

    DSK6713_LED_init();

    comm_poll(); //init DSK, codec

    while(1) //infinite loop

        {

        if(DSK6713_DIP_get(3) == 0) //if SW#3 is pressed

            {

            i=0;

            recording = 1; //start recording

            while (recording == 1)

                {

                DSK6713_LED_on(3); //turn on LED#3

                buffer[i++] = input_left_sample(); //input data

                if (i>2000)
                    while(1)    /* Need to wait in loop until key get released */
                    {
                    if (DSK6713_DIP_get(3)==1) //if SW#3 lifted

                        {

                        recording = 0; //stop recording

                        DSK6713_LED_off(3); //turn LED#3 off
                        break;
                        }
                    }
                }

            }

        if(DSK6713_DIP_get(0)==0) //if SW#0 is pressed

            {

            i=0;

            playing = 1; //start playing

            while (playing == 1)

                {

                DSK6713_LED_on(0); //turn on LED#0

                output_left_sample(buffer[i++]); //output data

                if (i>2000)
                    while(1)    /* Need to wait in loop until key get released */
                    {
                        if (DSK6713_DIP_get(0) == 1) //if SW#1 is lifted

                            {
        
                            playing = 0; //stop playing
        
                            DSK6713_LED_off(0); //turn LED#0 off
                            break;
                            }
                    }

                }

            }

        }

    }

  • Thanks for your suggestion...but I've tried it and still doesn't work...same problem...

    Thanks anyway for your help...

  • Kushant,

    Since you are copying code from a textbook and expect full success without doing anything else, I must assume you are working in a college or university environment. What is the goal of this assignment?

    • Turn on the DSK, load the code, and see that it works?
    • Find a program in a book that meets your needs?
    • Debug and test a program to understand how to write and debug DSP programs?
    • Find resources online to fix any problems that are unexpected?

    I am a bit comfused by your conflicting items:

    kushant vyas - title said:
    what is wrong with my code?

    kushant vyas said:
    I dont think there is any problem with the code.

    In the title, you assume something is wrong with the code and the error's identification. In the next statement, you no longer think there is a problem. If there is not a problem with your code, where else can there be a problem?

    Can the problem be in your board or your power supply or your other peripherals like the microphone or speaker?

    To determine the relevance of any of these items, you must debug the situation.

    You will want to follow the advice of an expert such as Titus S and use the emulator if the simple process of elimination of board/power/peripheral fails you. If you do not know how to use CCS and the emulator, then please go to the TI Wiki Pages and search for "c6713 training" (no quotes) and go through the archived training class. It will also include example labs and solution files that you can run.

    Good luck and good learning.

    Regards,
    RandyP

  • Hi Kushant,

    In addition to the RandyP suggestions,

    Have a try the following suggestions:

    1) If you debug through CCS with emulator then debugging is easy & you will learn debugging techniques and code flow etc., Eventually you will gain lot of debugging experience.

    2) Try to debug your code with your LEDs status; that is, use the this fn "DSK6713_LED_off(3)" or "DSK6713_LED_on(3)" to know the status & where you are.

    Try to use other LEDs too if any.

    3) I have doubt on "if (i>2000)" that how your code will behave if "i<2000" and try to use "else" part.

    I hope that the LED3 will be in OFF state in any status (if you released before/after the 'i>2000' samples)

    Note:

    I have not modified the audio "play" part

    void main()

    {

    short recording = 0;

    short playing = 0;

    for (i=0 ; i<N ; i++)
    buffer[i] = 0;

    DSK6713_DIP_init();

    DSK6713_LED_init();

    comm_poll(); //init DSK, codec

    while(1) //infinite loop

        {

        if(DSK6713_DIP_get(3) == 0) //if SW#3 is pressed

            {

            i=0;

            recording = 1; //start recording

            while (recording == 1)

                {

                DSK6713_LED_on(3); //turn on LED#3

                buffer[i++] = input_left_sample(); //input data

                if (i>2000)
                    while(1)    /* Need to wait in loop until key get released */
                    {
                    if (DSK6713_DIP_get(3)==1) //if SW#3 lifted

                        {

                        //TODO : print 'i' value here to know whether the value of 'i' is more than expected
                        //TODO : You can turn ON combinations of LEDs 2 & 3 (if any) if you wish to know the 'if' part status
                        recording = 0; //stop recording

                        DSK6713_LED_off(3); //turn LED#3 off
                        DSK6713_LED_on(2); //turn LED#2 on
                        break;
                        }
                    }
                else
                    while(1)    /* Need to wait in loop until key get released */
                    {
    //                if (DSK6713_DIP_get(3)==1) //if SW#3 lifted

    //                    {

                        recording = 0; //stop recording

                        //TODO : print 'i' value here to know whether the value of 'i' is less than expected
                        //TODO : You can turn ON LED#2 (if any) if you wish to know the 'else' part status
                                                
                        DSK6713_LED_off(2); //turn LED#2 off
                        DSK6713_LED_off(3); //turn LED#3 off    //eventually the LED3 will be in OFF status
                        break;
    //                    }
                    }

                }

            }

        if(DSK6713_DIP_get(0)==0) //if SW#0 is pressed

            {

            i=0;

            playing = 1; //start playing

            while (playing == 1)

                {

                DSK6713_LED_on(0); //turn on LED#0

                output_left_sample(buffer[i++]); //output data

                if (i>2000)
                    while(1)    /* Need to wait in loop until key get released */
                    {
                        if (DSK6713_DIP_get(0) == 1) //if SW#1 is lifted

                            {
        
                            playing = 0; //stop playing
        
                            DSK6713_LED_off(0); //turn LED#0 off
                            break;
                            }
                    }

                }

            }

        }

    }

  • Hi Kushant,

    Have you figured out the problem?

  • No...not yet.. my college doesn't have emulator so i cannot figure out what is the problem...i am sure that audio is not getting stored in memory but why this is happening, I am still trying to figure out... will post if anything happens... thanks.
  • Hi Kushant,

    You can find very low cost emulators (~80$) from the below link.

    http://www.ti.com/tool/xds100

  • Kushant,

    Is the DSK6713 part of your instruction material? Has it been covered in class or has any material been offered to you for understanding how to use it?

    The DSK6713 has an on-board emulator so all you need in terms of hardware is to connect a USB cable from your PC to the DSK6713.

    If there is no one to teach you how to use this board, I suggest you go to the online archived class on the TI Wiki Pages. Search the TI Wiki Pages for "c6713 training" (no quotes) to find the workshop that uses your board and explains how to use your board. You will also learn how to debug code in that course, or at least the tools available for debugging code.

    Regards,
    RandyP