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.

Help using TMS320C6713 DSK



I want to generate a sine signal with 4 diferent frecuencys depending on which dip switch is pressed. The code works well but only the last "if" routine change the frecuency, I don't know why the previous if routines disables imean if i only use 1 dip to change frecuency it works well but if i use 2 or more only the last one works. Can anyone help me, this is the code:

#include <math.h>

float    x[1000],y[1000];
int        n,N=1000,f;


void main ()
{
 DSK6713_LED_init();
 DSK6713_DIP_init();

 while(1)
 {
  if(DSK6713_DIP_get(0)==0)
    {
     DSK6713_LED_on(0);
     f=50;      
    }
  if(DSK6713_DIP_get(1)==0)
    {
     DSK6713_LED_on(1);
     f=100;
    }
  if(DSK6713_DIP_get(2)==0)
    {
     DSK6713_LED_on(2);
     f=200;
    }
  if(DSK6713_DIP_get(3)==0)
    {
     DSK6713_LED_on(3);
     f=500;
    }

  else
    {
     DSK6713_LED_off(0);
     DSK6713_LED_off(1);
     DSK6713_LED_off(2);
     DSK6713_LED_off(3);
     f=10;
    }

   for (n=0;n<=N;n++)
      {
        x[n]=10*sin(6.28*f/8000*n);
        y[n]=cos(6.28*n/N);
      }
 }
}

  • Rodrigo,

    Welcome to the TI E2E forum. I hope you will find many good answers here and in the TI.com documents and in the TI Wiki Pages. Be sure to search those for helpful information and to browse for the questions others may have asked on similar topics.

    This is a perfect opportunity for you to learn the use of the CCS debugger. Whether you are using the simulator or the emulator, you can build, load, and run your program, and then use the CCS tool for debugging.

    In your case, set a breakpoint inside the while(1) loop, run to that breakpoint, then single step to see which lines of code are being executed. Use the "source single step over" button for convenience.

    As you step through your code, you will see which lines are being executed. This will help you understand the structure and use of the if-clause and the if-else-clause.

    You can run to the breakpoint again, then change the DIP switches. You will then see different sequential behavior as you step through the code.

    If you have questions on the use of CCS, we may be able to answer some of those here, but you may also want to post to the Code Composer Forum instead; it is under Development Tools.

    Regards,
    RandyP

  • Greetings,

    In your While (1) you have

    if condition1

        do something1.

    if condition2

        do something2.

    etc...

    your will execute the last true condition, which will override all the previous true conditions.

    You may want to revise to

    if

    else if

    else

    or use a switch on a  DSK6713_DIP_get(ALL)

    Good Luck,

    Sam