Timing Calculations


Time to remove 1 byte from buffer:

128Kbps / 8 bits per byte = 16KB per second

1 / 16KBs = 62.5µs per byte


Time to decode 256 bytes (block size)

256 * 62.5µs per byte = 16ms

Time to insert 1 byte into buffer

SPI clock = system clock / 16 = 250KHz

8 bits per byte / 250 KHz = 32µs per byte


Time to insert 1 data block

256 * 32µs per byte + memory latency = 8.192ms + memory latency

To ensure maximum buffer use is 250 bytes (assume memory latency = 0)

Max buffer size = (# bytes in buffer when read is requested) + (bytes added) - (byte that leave buffer in time to fill)
250 bytes = x + 256 bytes - (8.192ms / 62.5µs per byte)
x = 125.072 = 125 bytes

Time to send second block request

(256 bytes-125 bytes) * 62.5µs per byte = 8.1875ms

Time allotted to prevent underrun

125 bytes * 62.5µs per byte = 7.8125ms