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 ![]()
Thanks for your help!