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