SPI (isd4002) problem

Hello guys.
I am trying to interface my arduino (actually it's an atmega328 programmed via the arduino IDE) to the isd 4002, which is a record/playback IC. All this with SPI.

I still had no luck making it work, but i'd say the hardware part is correct, since i have succesfully made it work with my picaxe board.

This is the code i use:

void setup(){
  byte clr;
SPCR=B01010011;
clr=SPSR;
clr=SPDR;

   delay(10);
   digitalWrite(10, LOW);  //10 is basically the SLAVE SELECT pin
   delay(10);
spi_transfer(B00000100); //powerup
delay(10);
   digitalWrite(10, HIGH);
   delay(10);

delay(1);
   digitalWrite(10, LOW);
   delay(10);
spi_transfer(B00000000);  //setrec
spi_transfer(B00000101);
delay(10);
   digitalWrite(10, HIGH);
   delay(10);

[...]

delay(10);
   digitalWrite(10, LOW);
   delay(1);
spi_transfer(B00001010); //STOPPWRDN com
delay(10);
   digitalWrite(10, HIGH);
   delay(10);
}
void loop(){}

void spi_transfer(volatile char data)
{SPDR=data;
while(!(SPSR & (1<<SPIF)))
{};
}

As you can see i desperately inserted a lot of delays to see if it would work. I've also tried using the Spi library (Arduino Playground - Spi) in default mode, and it didn't work. I've also tried using shiftOut and still no luck. The latest arrangements were taken from here:http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1213217330/5#5 and they include the spi_transfer function you can see at the end and the SPCR which is set at the beginning.

I don't know if it helps, but the picaxe code uses hardware spi set to mode 00 ((CKP=0, CKE=1, SMP=0) as written on the manuals) and it's quite similar to the above program, only that instead of spi_transfer it has hspiout (not defined by me).

I can't understand what's wrong :frowning:

Thanks for your help!

I haven't used this device but have just had a look at the data sheet. It says all instructions are 16 bits long. So why have you got some 8 bit transfers?
Yes you have two 8 bit transfers at :-
delay(10);
spi_transfer(B00000000); //setrec
spi_transfer(B00000101);
delay(10);
But you have only 8 bit transfers at:-
delay(1);
spi_transfer(B00001010); //STOPPWRDN com
delay(10);
Just because the data sheet shows this command as:-
0X01X
doesn't mean you can just ignore those register bits, you still have to clock them it, it is just that the chip will not do anything with them.

alright i'll try. Still with the picaxe it works fine if i send just 8 bits for those functions that do not need an address.

UPDATE: It still doesn't work. I've added a "spi_transfer(B00000000);" before the commands that were only sending one byte.