Hello,
I try to control my Recording Playback Module ISD1760 with adruino UNO, I helped myself different topics and information found on google but it does not work properly.
I can start playing with the command 'play' but then I do nothing more control. I want to read a single sound I recorded but for now I can not.
My code:
#include <SPI.h>
//opcodes
#define PU 0x01 //Power Up the device
#define STOP 0x02 //Stop the current operation
#define RESET 0x03 //Reset the device
#define CLR_INT 0x04 //Clear interrupt and OEM bit
#define RD_STATUS 0x05 //Return Returns status bits & current row counter in first 1st 2 bytes and operating status in 3rd byte
#define RD_PLAY_PTR 0x06 //Returns status bits & current row counter in 1st 2 bytes and Play pointer in 3rd & 4th bytes
#define PD 0x07 //Power Down
#define RD_REC_PTR 0x08 //Returns status bits & current row counter in 1st 2 bytes and Record pointer in 3rd & 4th bytes
#define DEVID 0x09 //Read the deivce ID register.
#define PLAY 0x40 //Play from current location without LED action until EOM or STOP command received
#define REC 0x41 //Record from current location without LED action until end of memory or STOP command received
#define ERASE 0x42 //Erase current message to EOM location
#define G_ERASE 0x43 //Erase all messages (not include Sound Effects)
#define RD_APC 0x44 //Returns status bits & current row counter in first 1st 2 bytes and the contents of APC register in 3rd & 4th bytes.
#define WR_APC1 0x45 //Write the data <D10:D0> into the APC register with volume setting from VOL pin
#define WR_APC2 0x65 //Write the data <D10:D0> into the APC register with volume setting from bits <D2:D0>
#define WR_NVCFG 0x46 //Write the contents of APC to NVCFG
#define LD_NVCFG 0x47 //Load contents of NVCFG to APC Register
#define FWD 0x48 //Forward play pointer to start address of next message. Forward will be ignored during operating, except Play
#define CHK_MEM 0x49 //Check circular memory
#define EXTCLK 0x4A //Enable/disable external clock mode
#define SET_PLAY 0x80 //Play from start address <S10:S0> to end address <E10:E0> or stop at EOM, depending on the D11 of APC
#define SET_REC 0x81 //Record from start address <S10-S0> to end address <E10:E0>
#define SET_ERASE 0x82 //Erase from start address <S10:S0> to end address <E10:E0> [Stop cmd is ignored]
#define DATAOUT 11 //mosi
#define DATAIN 12 //miso
#define SPICLOCK 13 //sck
#define SLAVESELECT 10 //ss
void setup() {
SPI.begin();
SPI.setBitOrder(LSBFIRST);
SPI.setDataMode(SPI_MODE3);
SPI.setClockDivider(SPI_CLOCK_DIV4);
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);
//SPCR = (1<<CPHA) | (1<<CPOL) | (1<<DORD) | (1<<SPE) | (1<<MSTR);
digitalWrite(SLAVESELECT,LOW);
spi_transfer(PU); // power up
spi_transfer(0x00);
digitalWrite(SLAVESELECT,HIGH);
delay(100);
digitalWrite(SLAVESELECT,LOW);
spi_transfer(CLR_INT); // clear interupt
spi_transfer(0x00);
digitalWrite(SLAVESELECT,HIGH);
delay(100);
}
void loop() {
digitalWrite(SLAVESELECT,LOW);
spi_transfer(PLAY); // play
spi_transfer(0); // data byte
digitalWrite(SLAVESELECT,HIGH);
delay(100);
ready_wait();
}
void ready_wait(){
byte byte1;
byte byte2;
byte byte3;
while(byte3<<7 != 128){
digitalWrite(SLAVESELECT,LOW);
byte1 = spi_transfer(RD_STATUS); // clear interupt and eom bit
byte2 = spi_transfer(0x00); // data byte
byte3 = spi_transfer(0x00); // data byte
digitalWrite(SLAVESELECT,HIGH);
}
}
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
}
I think we should rather use set play but I do not know how to retrieve my address her, and how to indicate with set_play.
Thank you for your help.