SPI library questions

Hi guys
I’m trying to interface my Arduino Mega 2560 with a TDA7439 (audio processor , with tone , gain control) {http://pdf.datasheetcatalog.com/datasheet/stmicroelectronics/4291.pdf}
This IC comunicates by serial interface to be programmed , but has not standards pins (MISO, MOSI,SS, CLK) for serial comunication but just SCLK and SDA lines. So, to “start” a comunication Arduino must send a falling edge of SDA line when CLK is HIGH and then send 3 byte with a clock pulse between them in mode 0 0 (polarity and phase). to “stop” the comunication arduino send a rising edge when CLK is HIGH.
So that is the problem: I need to program Arduino to send the right string in SDA with the right time respect the CLK signal, so
I’m using the SPI library and with transfer() function everything seems easy , but I don’t know exactly what this function do.
does It make CLK oscillating only when transfer() is called?
Is strictly necessary to call SPI.begin() to start a serial comunication with other devices?
I attach my sketch for a look:
I’ve declared a void function (byte WORD1, byte WORD2, byte WORD3) to send the 3 words via serial in the right way.
the void loop() is not completed yet , What I really need to know is if this function correctly send the data bytes .

#include <SPI.h>
int SMOSI=51;
int SCLK=52;
int Ss=53;
byte address=10001000;
void setup() {
void loop() {
byte InputGain=map(analogRead(A1),0,1023,0,16);
byte Volume=map(analogRead(A2),0,1023,0,40);
byte BassGain=analogRead(A3);
int MidGain=analogRead(A4);
int Treble=analogRead(A5);
int SpeakerGain=map(analogRead(A6),0,1023,0,56);
//funzione di trasmissione seriale lungo le linee MOSI e CLK (piedini 51, 52);
void serialToTDA(byte WORD1, byte WORD2 , byte WORD3)
{// start
//transfer address of TDA3974

but just SCLK and SDA lines

That looks like I2C. The Wire library is for I2C communication.

That's truee ! I haven't seen that library :sweat_smile:, so now I try to recreate the serial function and will let you see!

There are examples in the IDE to get you started. I2C is really pretty easy to use as the handshaking is taken care of by the library.

what about aknowledge pulse?
I'd like to work without, so does Wire.write() expect a AKNOWLEDGE signal from external device?

my device use a 8 bit address so I should I set the
Wire.begintrasmission() ?

Do you have your device connected to SDA and SCL? Remember the pullup resistors (one 4.7K from Vcc to SDA and one 4.7K from SCL to Vcc). I will provide a sketch (by Nick Gammon) to check I2C communication and confirm the address.
Upload and run.

#include <Wire.h>

void setup() {
  Serial.begin (115200);  // change this to the Serial monitor baud rate

  // Leonardo: wait for serial port to connect
  while (!Serial) 

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  for (byte i = 1; i < 120; i++)
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

Most I2C addresses are 7 bit with the 8th bit for read or write.
In setup() you put Wire.begin() to start I2C as master.
The ACK is handled by the library.
Wire.beginTrnsmission() will initiate communication then use Wire.write to send.