Chat here about code rewrites, mods, etc... with respect to the github project https://github.com/esp8266/Arduino

Moderator: igrr

User avatar
By mph070770
#57941 I'm preempting problems and seeking prior advice before I start...

I have investigated using the internal ADC on the ESP8266 for audio recording. My requirements are low - 8KHz sampling (ideally at 16b but because of what I say next, that's a moot point). It seems that even with WiFi disabled etc, I can't get analog_adc to run faster than 5KHz. So, i'm moving to an SPI solution, described here: https://github.com/sven337/jeenode/blob ... t/xmit.ino using this chip: http://www.esp8266-projects.com/2015/04 ... p8266.html

I want to record the audio to SPI flash (using SPIFFS) and it can happen when WiFi isn't connected if that helps performance. I've successfully written audio to SPI on other platforms at similar or higher bit rates without an issue.

Will SPIFFS handle a datarate of 8KHz 16 bit along with the simultaneous audio sampling?

Does anyone have any advice on the best way to do it? I'm assuming timer based, with a couple of 1K buffers, writing flip/flop to the SPI. Can the SPI write be DMAed, for example, so that it doesn't impact on the audio sampling?

Thanks!
User avatar
By mph070770
#58437 Ok, so no reply to my original post so perhaps there isn't much knowledge out there on this specific goal.

I now have the ADC working but my worries seem to have been realised - I can't sample at 8KHz and write to flash simultaneously. It seems that SPIFFS isn't fast enough. When I am writing, the SPIFFS write activity seems to make the timing of the ADC ISR change.

I've tried turning off caching for the flash (as I believe it writes a 4K page at a time by default) so that my ADC writes are written as they occur but this didn't seem to help. I'm wondering if I can go lower level and use ESP.flashWrite and write my data "raw" (I know I'll have to erase the sectors first). Does anyone know if this will be faster?

Can anyone suggest any solutions?
User avatar
By RichardS
#81563 I have found the answer is YES and NO.

YES if you start with a formatted SPIFFS filesystem.

NO if you have written and delete files and added files... etc etc.... it can become slow....

Use a ESP32 with 4MB RAM and record into it! :-)

RichardS