First, I2C is probably a poor choice for sampling audio: it has a lot of protocol overhead, relatively slow and has no strict timing guarantees. SPI would be a much better choice. Also, if you make any firmware changes to how the IOIO behaves in response to a writeRead request, you need to make the appropriate changes on the client side, to expect a different kind of response. Your approach of changing the state machine seems reasonable. You should be able to increase the buffer size by reducing some of the other buffers. There's an overly large one here: https://github.com/ytai/ioio/blob/master/firmware/app_layer_v1/protocol.c#L148 which I have never bothered optimizing.
On Mon, Jul 14, 2014 at 9:36 PM, Léopold Arnault <[email protected]> wrote: > Hello, > > I’m using the IOIO firmware to program a PIC connected to DSPs. I want to > receive digital data from these DSPs via I2C communication, and write this > data to a SD card. My problem is that the data transfer is too slow: by > calling repeatedly the I2CWriteRead function in i2c.c, I can read a 4 byte > register at barely 60Hz. As I wish to receive audio data through I2C, this > frequency should reach at least several kHz. I was wondering if it could be > possible to modify the code to make a burst read on a single register > address input in order to increase the reading speed? > > What I already tried: > -Modify the state machine in the MI2CInterrupt function (i2c.c): go back > to “STATE_WRITE_DATA” after “STATE_ACK_READ_DATA” when there are no "bytes > remaining", and rewrite the same address. It leads to error (line 313 in > the original file) and I don’t really know why. (The code to write the > received data to the SD card is in the “STATE_ACK_READ_DATA” state, data is > written to the SD when there are no bytes remaining). > > -Call repeatedly the I2CWriteRead function. In order to prevent buffer > overflow, I needed to add a 10 ms delay after each call. It works but it > makes the process very slow. Here is my code: > > void SIGMA_READ_REGISTER( int devAddress, int address, int nbRead ){ > > unsigned char dataAddr[2] = {0x00,0x00}; > dataAddr[0] = ((address>>8) & 0xFF); //grab the top 8 bits of the > address > dataAddr[1] = (address & 0xFF); //grab the bottom 8 bits of the > address > int i; > for (i=0;i<nbRead;i++){ > I2CWriteRead(0, devAddress, &dataAddr[0], 2, 4 ); > Delayms(10); > } > } > > -Increase the Tx buffer size. It can't be more than 512 (otherwise it > leads to linking memory errors). > > Is there a way to read continuously without calling the I2CWriteRead > function each time? Or is it possible to accelerate the reading process? > > Thanks for your time and consideration. > > Léopold > > -- > 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.
