SerialFlash write speed

Status
Not open for further replies.

jcarruthers

Well-known member
Hi all,


Can anyone comment on the feasibility of using the SerialFlash library to store audio sampled in real time?

At the moment I'm using a sample rate of 20kHz and storing it in RAM — so about 50us between samples. Obviously 64Kb runs out pretty quickly.

How quick is it to write two bytes (16-bit signed) to flash memory?


James
 
Can anyone comment on the feasibility of using the SerialFlash library to store audio sampled in real time?

With most chips, writing 256 bytes takes about 700 microseconds.

It's much slower if you write less than 256 at a time, so plan on collecting up 128 samples to write all at once.
 
Thanks Paul.

Is that going to stall my sampling whilst writing to the flash? 700 microseconds is a long time if I'm sampling every 50 or so.

It doesn't actually matter if 10 microseconds to write a couple of bytes — if it'll fit between the samples.
 
SerialFlash will return quickly and the hardware actually writes while your program runs.

If you attempt to read before the write is done, SerialFlash will automatically use the suspect & resume feature, which allows you to read in about 20 microseconds, but it does add about 30 microseconds to the entire write, due to suspending it.

If you attempt another write or anything else that isn't a read while the write is still in progress, SerialFlash will wait for the previous write to complete.
 
Thanks again Paul.

20 microseconds to read a whole 256bytes?

This should work out fine then and I am sure it'll be ok.

At the moment I am pushing the samples in to an array but also playing it back at the same time. But I am sure I can work out a strategy to keep a buffer on the Teensy.


James
 
Oh, no, that's 20 us to just stop the write-in-progress. Then the read takes about 2 microseconds, plus 1/3rd of a microsecond per byte.

So reading 256 bytes takes approx 88 microseconds, plus 20 more if a write is in progress.

Writing 256 takes about 700 microseconds, but it varies with different chips. Some are a bit faster, but not a lot faster.
 
Thanks Paul.

All seems quite straight forward then.

Sampling 128 samples (256 bytes) takes 6,400 microseconds @ 20kHz. So plenty of time to both write and read from the Flash in between.

I figure having both a reading and writing buffer for the flash —*and then another reading and writing buffer for the sampling and playback.

As soon as it has sampled the last value it shoves the buffer in to the writing buffer and goes and writes it to flash.

As soon as it starts playing the first value from the playing buffer it starts reading the next chunk from the flash in to the reading buffer.

Something like that anyway.
 
Also — I am presuming that this is quicker/more robust than an SD card?

The latency figures I've seen seem not so good.
 
Status
Not open for further replies.
Back
Top