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);
}
}
}