you are basically saying that running multi-sector read/writes on the SD card does not help because of the latency of the USB?
No, multi-sectors read/write is useful, because we can save protocol over head of repeated single-sector read/write.
The idea is that,
Either single- or multi-sector read/write, we can pause SPI clock at any time, even at the middle of 512 bytes sector read/write. We don't need to finish one sector at a time.
For example, this sequence is allowed.
1) First 64 bytes of a sector is read from SD card.
2) Pause SPI clock
3) This 64 bytes is sent over bulk IN EP.
4) When USB transaction completes, restart SPI clock and another 64 bytes is read out from the SD sector.
5) back to 2)
In this sequence, the SD process and USB process still run alternately.
To overlap both processes, we split them, with a cyclic buffer between them.
SD read out --> cyclic buffer --> USB packet send
SD process reads out sectors until the cyclic buffer goes full, in a unit of 64 bytes.
While the cyclic buffer is full, SD process pauses.
USB process sends 64 bytes packets from the cyclic buffer, until it goes empty.
While the buffer is empty, this process pauses.
The USB transaction is processed by the USB engine. The USB firmware code works just at the start and end of a transaction. While the USB engine is sending a transaction, the firmware can run SD process.
In this way, both processes are overlapped.
These options speed up the transfer more.
- ping-pong on USB EP
- SPI with DMA
post edited by chinzei - 2011/10/06 08:20:51