SPI help! w/ISD15100 ChipCorder

I’m attempting to interface with a ISD15100 series chipcorder and i’m having a bit of trouble. This is a test code that should record a 30second message and then play it back. I’m screwing something up. After a message is recorded, you have to request the message address. I think i’m not receiving this message address information properly. Let me know if anyone can help! Thanks!

#include <SPI.h>
int recPin=7;
int playPin=6;
int recState;
int playState;
char address[4];
int ss=10;

void setup(){
  Serial.begin(9600);
  Serial.print("main");
  pinMode(ss,OUTPUT);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE3);
  
  digitalWrite(ss,LOW);
  SPI.transfer(0x10); // power up
  digitalWrite(ss,HIGH);
  delay(100);

  digitalWrite(ss,LOW);
  SPI.transfer(0x46); // clear interupt and eom bit
  digitalWrite(ss,HIGH);
  delay(100);
  
  
}
void loop()
{
 recState = digitalRead(recPin);
 playState = digitalRead(playPin);
 if(recState == HIGH)
 {
   writeData();
 }
 if(playState == HIGH)
 {
   playData();
 }
 } 
 
void writeData(){
  Serial.print("Recording");
  digitalWrite(ss, LOW);
  SPI.transfer(0X38);  //Record command
  digitalWrite(ss, HIGH);
  delay(30000);
  Serial.print("Stop");
  digitalWrite(ss,LOW);
  SPI.transfer(0x2A);
  digitalWrite(ss, HIGH);
  delay(10);
  request();
}
char* request()
{
  Serial.print("Requesting Address");
  digitalWrite(ss, LOW);
  SPI.transfer(0X42);
address[1] = SPI.transfer(0x00);
address[2] = SPI.transfer(0x00);
address[3] = SPI.transfer(0x00);
  digitalWrite(ss, HIGH);
  delay(10);
  Serial.println(address[1]);
  Serial.println("");
  Serial.println(address[2]);
  Serial.println("");
  Serial.println(address[3]);
  Serial.println("");
  return address;
}
void playData(){
  Serial.print("Playing");
  digitalWrite(ss, LOW);
  SPI.transfer(0X38);
  SPI.transfer(address[1]);
  SPI.transfer(address[2]);
  SPI.transfer(address[3]);
  digitalWrite(ss, HIGH);
  delay(10);
}

http://dl.dropbox.com/u/20242263/ISD15100_Design_Guide_v1.4.pdf

I realise it's been a little while since your post, but I'm also trying to get this chip working and found your thread. From threads I've found which relate to other ISD ChipCorders, and looking at your code, I think you may be losing the first byte of the address because your first address byte is returned when you clock in the request command itself, so your code should read: address[0] = SPI.transfer(0X42); address[1] = SPI.transfer(0x00); address[2] = SPI.transfer(0x00);

to get all three bytes of the address. I might be wrong, as I'm not even as far along as you are getting the chip working, like I say I'm just extrapolating from laterally realted threads I've found. Hope it helps! :)

I can't agree with this. SPI transfers are two-way, in the sense that as one bit is sent another is received. Thus you can never get a response to a query in the same transfer (by the time the device has received the byte the transfer is over).

http://gammon.com.au/spi

I can't say why the original problem occurs, but his way looks more right to me. Subject to looking at the data sheet, which I haven't done.

I'm, not familiar with the chip but I'd d day the original code

  SPI.transfer(0X42);
address[1] = SPI.transfer(0x00);
address[2] = SPI.transfer(0x00);
address[3] = SPI.transfer(0x00);

looks good, send a command then get 3 bytes.

What's the purpose of the two SS writes here?

  digitalWrite(ss, LOW);
  SPI.transfer(0X38);  //Record command
  digitalWrite(ss, HIGH);
  delay(30000);
  Serial.print("Stop");
  digitalWrite(ss,LOW);
  SPI.transfer(0x2A);
  digitalWrite(ss, HIGH);

It won't affect most chips but some actually use the SS signal to sync internal stuff. It may even be needed by this chip, just checking.


Rob

Looks like he is recording for 30 seconds, so that doesn't seem unreasonable.

Yep, that's reasonable.


Rob