SPI arduino uno

I have an IC with this in manual:
SPI:Data is transferred with a clock at 1MHz. Data is valid on the rising edge of CLK.
The idle state of these lines is HI. Each byte (8-bits) is transferred at the request of the host.
To request a byte, the SYNC line transitions HI LO HI. After this, a byte is transferred
when it is ready. Data is only transferred when available so there may be some delay between
the SYNC line request and the actual transfer taking place.
Data is transferred with a clock at 1MHz. Data is valid on the rising edge of CLK.

How to implement this?

I have tried:

SPISettings  S(1000000, LSBFIRST, SPI_MODE3);


void setup() {
  pinMode(SS, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, INPUT);
  pinMode(13, OUTPUT);
  pinMode(13, HIGH);
  digitalWrite(SS, HIGH);
  digitalWrite(11, HIGH);
  delay(10);
  Serial.begin(115200);
  SPI.begin();
  digitalWrite(SS, LOW);

}
void loop() {
   byte p;
  SPI.beginTransaction(S);
  p = SPI.transfer(B1);
  delay(10);  
  SPI.endTransaction();
  Serial.println(p);
  
  
}

I got first byte, but than only 255 and nothing else.

What's meaning by "the SYNC line transitions HI LO HI."???(I think this is the problem...)

jeninicicek:
What's meaning by "the SYNC line transitions HI LO HI."???(I think this is the problem...)

I'm guessing this refers to the slave-select line (often pin 10 on an Uno - but it can be any pin). Normally your program needs to put the required data on the pin - it is not automatic. So maybe a sequence like

digitalWrite (syncPin, HIGH);
digitalWrite (syncPin, LOW);
digitalWrite (syncPin, HIGH);

HOWEVER ... This seems rather strange "Data is only transferred when available so there may be some delay between the SYNC line request and the actual transfer taking place." That sounds as if the device (rather than the Uno) is acting as master. AFAIK the Arduino SPI library only works if the Uno is the master.

You need to post a link to the datasheet for the device.

...R

Are we allowed to know what chip this is? Complete datasheet?

I suspect that SYNC is another line, not one of the standard SPI lines. You may need to toggle that, then start the SPI transfer.

If you want help post a link to the datasheet - as requested in Replies #1 and #2

It should not be necessary to say the same thing three times.

...R

Datasheet, that I have(first sites, other sites are about keyboard keys matrix and other parts)

ymz702.pdf (128 KB)

jeninicicek:
I got first byte, but than only 255 and nothing else.

What's meaning by "the SYNC line transitions HI LO HI."???(I think this is the problem...)

From the datasheet you linked...

Setup a synchronous SPI communication (1MHz SPI clock). For this, pin 24 of the YMZ702 acts as
a data handshake or acknowledge. So if you receive one byte you have to pull this pin once before
the YMZ 702 will send the next byte.

It looks like you need to have an ACK line that is normally high and briefly pull it low each time you receive a byte so the next one can be sent.

jeninicicek:
Datasheet, that I have

That datasheet shows the connections to an Attiny. Perhaps it also has some example program that you could share with us?

...R

But how to pull the Ack line, when the pin is blocked by SPI(http://playground.arduino.cc/Code/Spi)? I tried stop and initialize SPI everytime(), but it is not working:

void loop() {
 byte p;

  SPI.end();
  digitalWrite(11,HIGH);
  digitalWrite(11,LOW);
  digitalWrite(11,HIGH);
  SPI.begin();
  SPI.beginTransaction(S);
  
  p = SPI.transfer(0);
  delay(10);
  
  SPI.endTransaction();
  Serial.println(p);

}

What is doing SPI.begin() and SPI.beginTransaction() with pins exactly?

I have no programs...(the person who sent me the datasheet, said that he has it from Armin Riemer of Ellevan band..., I don´t know, who is it.)

jeninicicek:
What is doing SPI.begin() and SPI.beginTransaction() with pins exactly?

RTFM

I have no programs...(the person who sent me the datasheet, said that he has it from Armin Riemer of Ellevan band..., I don´t know, who is it.)

Info on the chip seems scarce (Google search found little) so it must be a proprietary Yamaha part.

...R

Looking at the datasheet I get impression the Arduino will be a SPI slave device as YMZ702 serial output pin 23 (SO) is connected to the MOSI pin on the tiny2313 BUT the tiny2313 has to generate the data clock and this implies it needs to be an SPI master. I think the protocol is possibly software defined instead of using the SPI hardware.

From what I have read I think...
SO, XCK and ACK are usually high
Arduino generates the XCK signal (maybe all the time?)

  1. Arduino briefly pulls ACK low to request a byte from the YMZ702
  2. YMZ702 sends a byte (maybe with a delay before sending if no keys pressed?)
  3. Arduino receives the byte
  4. Arduino loops back to 1 to receive the other 2 bytes (3 bytes per key down/up)

Riva:
I get impression the Arduino will be a SPI slave device

Me too.

...R

Robin2:
Me too.

…R

I tried arduino to be slave(Gammon Forum : Electronics : Microprocessors : SPI - Serial Peripheral Interface - for Arduino) yesterday. But there is no clock signal then(I tried to pull SYNC pin already)…

I don't know anything about the chip you are trying to use. But your Reply #11 leads me to think you may be able to solve that problem by using one the Arduino's hardware timers to produce a clock signal on one of the PWM pins. Study the Atmel datasheet.

...R