im trying to interface a winbond chipcorder isd1700 via spi, i have it working with standalone buttons right now so i know it works, i have the spi lines hooked to the arduino, and this is sorta what i have so far.
can i use the opcodes like i am? do i need to do anything special for the hex codes, should i convert them to decimal? any hints on something im doing blatantly wrong?
i couldn't find a spi speed in the manual so i assumed the lowest
the datasheet specified
PU then CLR_INT then PLAY as a sample execution sequence
each of these command bytes is to be followed by a 0x00 value
the code doesn't work as is, but i don't exactly expect it to either. looking for some advice so i can work on it some more tommorrow thanks!
if your a masochist, here is the datasheet
http://www.techs-store.com/support/manual/isd1700/isd1700_eman.pdfmost of the spi stuff starts on page 31
#define DATAOUT 4 //mosi
#define DATAIN 5 //miso
#define SPICLOCK 6 //sck
#define SLAVESELECT 7 //ss
//opcodes
#define PU 0x01
#define STOP 0x02
#define RESET 0x03
#define CLR_INT 0x04
#define RD_STATUS 0x05
#define RD_PLAY_PTR 0x06
#define PD 0x07
#define RD_REC_PTR 0x08
#define DEVID 0x09
#define PLAY 0x40
#define REC 0x41
#define ERASE 0x42
#define G_ERASE 0x43
#define RD_APC 0x44
#define WR_APC1 0x45
#define WR_APC2 0x65
#define WR_NVCFG 0x46
#define LD_NVCFG 0x47
#define FWD 0x48
#define CHK_MEM 0x49
#define EXTCLK 0x4A
#define SET_PLAY 0x49
#define SET_REC 0x81
#define SET_ERASE 0x82
void setup() {
byte clr;
pinMode(DATAOUT, OUTPUT);
pinMode(DATAIN, INPUT);
pinMode(SPICLOCK,OUTPUT);
pinMode(SLAVESELECT,OUTPUT);
digitalWrite(SLAVESELECT,HIGH); //disable device
SPCR = B01111111; //data lsb, clock high when idle, samples on falling
clr=SPSR;
clr=SPDR;
delay(10);
}
void loop() {
digitalWrite(SLAVESELECT,LOW);
spi_transfer(PU); // power up
spi_transfer(0x00); // data byte
digitalWrite(SLAVESELECT,HIGH);
delay(100);
digitalWrite(SLAVESELECT,LOW);
spi_transfer(CLR_INT); // clear interupt and eom bit
spi_transfer(0x00); // data byte
digitalWrite(SLAVESELECT,HIGH);
delay(100);
digitalWrite(SLAVESELECT,LOW);
spi_transfer(PLAY); // play
spi_transfer(0x00); // data byte
digitalWrite(SLAVESELECT,HIGH);
delay(100);
delay(10000);
}
char spi_transfer(volatile char data)
{
SPDR = data; // Start the transmission
while (!(SPSR & (1<<SPIF))) // Wait for the end of the transmission
{
};
return SPDR; // return the received byte
}