Arduino Yun SPI on ICSP connector (try to connect to a isd 1760 shield)

Hi all,

i have a fully fonctionnal ISD1760 (audio shield) working on an arduino uno, using pins 10 to 13 for SPI pins, but on an arduino yun, i can't got it working.
I've found that corresponding SPI pins are 14,15,16,17. For the 14,15,16, it's on the ICSP connector (as explained on Step by Step Guide to the Arduino Leonardo : 7 Steps (with Pictures) - Instructables ), but for pin 17 , i really don't find the answer.
I tried on RX led as on other models. Many weeks on that problem, and can't succeed. =(

Anyone ever got it working (anything with MOSI,MISO,SS,SCK connected to icsp connectors of an arduino yun) ?

Thanks for your help. :slight_smile:

my isd1760 shield is this one :
http://www.google.fr/imgres?imgurl=http://s1.electrodragon.com/wp-content/uploads/2013/05/ISD1760-Recording-Playback-Module-1.jpg&imgrefurl=http://www.electrodragon.com/product/isd1760-recording-playback-module/&h=997&w=1200&sz=652&tbnid=hRmEuBhUObwhSM:&tbnh=106&tbnw=127&zoom=1&usg=__5BOPRuEU8vZOGY3CppAx1D9n8_I=&docid=8Wkn2Efa_7hv0M&sa=X&ei=PjjlUsu0G-me0QWJjoCwDA&ved=0CDkQ9QEwAA&dur=1588

and my code is:

#define DATAOUT 16 //11-MOSI (bleu)
#define DATAIN 14 //12-MISO (vert)
#define SPICLOCK 15 //13-SCK (marron)
#define SLAVESELECT 17 //10-SS (rouge)

#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 to end address E10:E0
#define SET_ERASE 0x82 //Erase from start address S10:S0 to end address E10:E0 [Stop cmd is ignored]

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);

//Moniteur série
Serial.begin(9600);

digitalWrite(SLAVESELECT,LOW); //Mettre le module en route
spi_transfer(PU); // Power Up
spi_transfer(0x00); // data byte
digitalWrite(SLAVESELECT,HIGH);
delay(100);
Serial.println(“Power Up”);

digitalWrite(SLAVESELECT,LOW); //Clear
spi_transfer(CLR_INT); // Clear interupt and EOM bit
spi_transfer(0x00); // data byte
digitalWrite(SLAVESELECT,HIGH);
delay(100);
Serial.println(“Clear”);
delay (3000);
Serial.println(MOSI);
Serial.println(MISO);
Serial.println(SCK);
Serial.println(SS);
}

void loop() {

// Lire un son enregistré dans la mémoire flash puis passe au suivant, en boucle
digitalWrite(SLAVESELECT,LOW);
spi_transfer(PLAY); // PLAY écouter le son pointé par le curseur
spi_transfer(0x00); // data byte
digitalWrite(SLAVESELECT,HIGH);
Serial.println(“PLAY”);
ready_wait(); //Attendre la fin de ce son
delay(3000);

digitalWrite(SLAVESELECT,LOW);
spi_transfer(FWD); // Décaler le curseur au son suivant
spi_transfer(0x00); // data byte
digitalWrite(SLAVESELECT,HIGH);
Serial.println(“FWD”);
}

// Fonction ready_wait
void ready_wait(){
byte byte1;
byte byte2;
byte byte3;
//Pour savoir si le son est terminé, tester le 1er bit du 3eme octet MISO
while(byte3<<7 != 128){
digitalWrite(SLAVESELECT,LOW);
byte1 = spi_transfer(RD_STATUS);
// Returns status bits & current row counter in first 1st 2 bytes
// and operating status in 3rd byte
byte2 = spi_transfer(0x00); // data byte
byte3 = spi_transfer(0x00); // data byte
digitalWrite(SLAVESELECT,HIGH);
}
delay(100);
} //Fin de la fonction

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
}

samok:
Hi all,

i have a fully fonctionnal ISD1760 (audio shield) working on an arduino uno, using pins 10 to 13 for SPI pins, but on an arduino yun, i can't got it working.

That this works on an Uno doesn't mean anything, as the AVR part of the Yun is compatible with the Arduino Leonardo. And the Leonardo product page specifically states:

SPI: on the ICSP header. These pins support SPI communication using the SPI library. Note that the SPI pins are not connected to any of the digital I/O pins as they are on the Uno, They are only available on the ICSP connector. This means that if you have a shield that uses SPI, but does NOT have a 6-pin ICSP connector that connects to the Leonardo's 6-pin ICSP header, the shield will not work.

hth,

Ralf

In my mind this only means that icsp header is now the only way to use spi on arduino yun. Not that all 6 pins must be used so that spi works. Anyway, on others leonardo based models, i've found some projets working (using RX led as the D17 port).
And spi is only a standard protocol, that needs MOSI/MISO/SCK/(sometimes SS) ports to work.
Even when i asked the arduino yun itself what is the value of variables "MOSI","MISO",... it answers 14,15,16,17. So i will be very surprised that all shields working on arduino uno,due,... now just don't work on arduino yun.

I'll continue to search any answer. If someone got an spi shield working on arduino yun, please let me know how.

Tadaaaaaaa! It works.

Effectively, SS pin is the right part of the RX led, other spi pins (miso, mosi,sck) are on the atmega iscp connector (6 pins on the right of the arduino yun sticker). Will add a new pin and will be perfect.
Hope this will help someone else fighting with spi on arduino yun or similar models.

:smiley:

That gets you SS alright but that is shared with the YUN Linux processor for communication. I am trying to debug an issue with an SDCARD, Audio board, and of course the SS native to the YUN. SD examples will work as long as I define the MOSI and SCK pins and add a short delay prior to doing any SD activity. The audio portion sharing the same SPI bus is not being as helpful. I'll try defining the pins as you stated above and see if that helps.