I'm reading an array of sensor on a periodic basis (every 10 milliseconds) and making some pre-parsing on the data before posting data to another MCU. I try to take care of the almost 192KB of available RAM that NP2 supports but some times other background running processes just hang up when some memory limit is reached.
The operation I'm taking about is very memory consuming so I decided to implement a "memory swapping" strategy by creating a library that writes data to disk (MicroSD) based on file segments and data block layout. A worker thread reads the cursor on the swapping area and takes the data back when needed. Data cursor is administered by the library.
It works perfectly but It slowed down the core loop because writing to the MicroSD and then reading again at a high rate seems to be very expensive or just very slow. I tried to find a 2GB MicroSD with a higher speed Class than Class 2, but they don't exist.
I also tried by formatting the MicroSD with different FAT32 allocation blocks and it worked at maximum rate by allocating blocks of 4096 bytes (using one allocation block on many writings therefore avoiding continuos allocation).
I wonder if is there another strategy or way to perform I/O at a high rate on the microSD card avoiding this bottleneck?