Hi! 1. There are no hard guarantees on the byte timing while using SPI. It is normal to have small gaps between groups of bytes. 2. It is not possible to invert MOSI or SS. SS can be inverted in firmware, but I believe the polarity of MOSI is fixed. 3. I don't see why fixed rate is important for your application. Normally such LED installations have a separate strobe signal that latches everything, so the timing of individual bytes doesn't actually matter. Is this not the case? 4. Do not call writeRead() from inside a batch, only writeReadAsync() or else your software might hang forever.
On Mon, May 12, 2014 at 8:00 AM, Sidharta Prahladsingh < [email protected]> wrote: > Hello, > > I have few questions on what I want to do. > > <https://lh4.googleusercontent.com/-ez6O-wfZRHM/U3DaTJ1_XzI/AAAAAAAACw8/Io7KgMwfFKA/w890-h503-no/2014-05-12>I > am trying to sent information from and android device to the ioio to an > FPGA board. I am using SPI protocol to send this info to the FPGA. The > information that needs to be sent is stored in a byte array in the phone > which is split in smaller arrays (64 bytes are max bytes that can be sent > in one package(?)) and sent to the ioio. For now I choose a speed of 8MHz. > I for now created a signal with alternating bits. From reading the > resulting output (on the MOSI pin) with an oscilloscope I get a signal as > seen in the picture to the right. This shows me that 8 bytes per approx. 3 > microseconds are sent with each containing 8 bits(which is correct). > > > - > *Is everything I assumed/explained/observed so far correct?(e.g. the max > package size) * > - > *is it possible to invert the MOSI or SS from the Android app code? * > - *Is there a way to decrease the 3 microseconds per 8bytes?* > > Altogether what would be more advantageous to us is to have a constant > flow of bits being sent at >1MHz(so no stop in between from initialization > of the stream. say if I send 16 bits, I do not want there to be a small > space of nothing between 2 bytes(8bits)). If above is true then SPI won't > be able to achieve this. > > - *Any advice on how to achieve this? Or is it just better to continue > with SPI?* > > I made a post before about what I am ultimately trying. I want to send a > picture with the android to the IOIO and make the IOIO sent it on to an > FPGA board which will drive a custom LED matrix system. The android will > send bytes with R,G and B values in that order for each pixel and that info > will be further handled at the FPGA. > > The code for sending the bytes through the IOIO is as follows: > >> @Override >> public void loop() throws ConnectionLostException { >> >> byte[] buffer_= buffer; >> int buffernum = (int) Math.ceil(buffer_.length/8); >> >> byte[] buffer1_= new byte[64]; >> byte[] buffer2_= new byte[64]; >> for (int i =0;i<buffernum;i++){ >> System.arraycopy(buffer_, i*64, buffer1_, 0, 64); >> if ((i+1)<buffernum){ >> System.arraycopy(buffer_, ++i*64, buffer2_, 0, 64); >> } >> try { >> ioio_.beginBatch(); >> Thread.sleep(1); >> >> if ((i+1)<buffernum){ >> spi_.writeReadAsync(0,buffer2_, buffer2_.length, >> buffer2_.length, null, 0); >> } >> spi_.writeRead(buffer1_, buffer1_.length, >> buffer1_.length, null, 0); >> ioio_.endBatch(); >> } catch (InterruptedException e) { >> // TODO Auto-generated catch block >> e.printStackTrace(); >> } >> } >> >> } >> > > -- > You received this message because you are subscribed to the Google Groups > "ioio-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/ioio-users. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "ioio-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/ioio-users. For more options, visit https://groups.google.com/d/optout.
