Interface TDA7439 with atmega 328p

Hey I am trying to interface TDA7439 with atmega 328p using the test circuit in the data sheet.
I am using the attached program but cannot get it to work.
Will some one let me know whats wrong in my code?

TDA7439_TTest_cod.ino (2.25 KB)

Hey I am trying to interface TDA7439 with atmega 328p using the test circuit in the data sheet.

What data sheet?

void setInput(int input){
  switch (input) {
    case 1: input = TDA7439_input_1;break;
    case 2: input = TDA7439_input_2;break;
    case 3: input = TDA7439_input_3;break;
    case 4: input = TDA7439_input_4;break;
  }
}

input is a local variable. Assigning a new value to it is pointless. The change will be lost when the function ends (which happens immediately after the assignment).

Aside from that, the code you posted does something. You didn't explain what it does. You want it to do something. You didn't explain what you wanted it to do. Hard to get from point a to point b with no clue where a or b are.

Thanks PaulS for the reply. My bad I did not explain more. So the TDA7439 is an audio processing IC which can multiplex audio sources, volume and 3 band Equalization with gain and attenuation. So here I want to writ a code to multiplex 4 sources, change volume, gain attenuation and bass,treble and middle according to the db given in the data sheet. Link for the datasheet:

http://www.st.com/web/en/resource/technical/document/datasheet/CD00010668.pdf

You’re doing some odd things, updating input / range / val variables in place -
you should lose all those assignments and write some mapping functions:

Lets look at setSnd:

void setSnd(int val, int range)
{
  switch (range)
    {
    case 1:range = TDA7439_bass;break;
    case 2:range = TDA7439_middle;break;
    case 3:range = TDA7439_treble;break;
    }   // uh-oh, no default case, have you considered that possibility?
  switch (val)
    {
    case -7:val = 0;break;   // very verbose way to do this - there's a clear pattern
    case -6:val = 1;break;   // to exploit here.
    case -5:val = 2;break;
    case -4:val = 3;break;
    case -3:val = 4;break;
    case -2:val = 5;break;
    case -1:val = 6;break;
    case 0 :val = 7;break;
    case 1 :val = 14;break;
    case 2 :val = 13;break;
    case 3 :val = 12;break;
    case 4 :val = 11;break;
    case 5 :val = 10;break;
    case 6 :val = 9;break;
    case 7 :val = 8;break;
    }   // uh-oh, no default case, have you considered that possibility?
	  
  writeWire(range, val);
}

(reformated a bit)

Conceptually this function takes a range code, and a val code,
and converts these to actual values for the writeWire call.

Do the conversion in a function - this is exactly what a function does best:

int device_range (int range)
{
  switch (range)
    {
    case 1: return TDA7439_bass;
    case 2: return TDA7439_middle;
    case 3: return TDA7439_treble;
    default:  // so what about this case - perhaps we need to flag an error?
      return range ;
    }
}

// each function does one thing, much easier to maintain
int device_val (int val)
{
  if (val >= -7 && val <= 0)  // exploit the obvious pattern in the mapping
    return val + 7 ;
  if (val > 0 && val <= 7)
    return 15 - val ;
  // so what about other cases?  perhaps flag an error
  return val ;
}

// Now setSnd is nice and simple, very clear.
void setSnd (int val, int range)
{
  writeWire (device_range (range), device_val (val) ;
}

Thank you MarkT for the wonderful clarification. How about for the the Input selection ? Does that work ?

did you solve the problem ? just wonder , because Im struggeling alittle my self. .