Permanent storage of configuration and run-time parameters is not straight forward with small, embedded solutions as the build in Flash only allow large pages and have a limited number of re-writes intended for program download only. Older MCU’s used a build in EEPROM for this purpose that have been removed from modern MCU’s, so we need to solve this ourselves. W25Q16 is a typical solution using a SO8 package to provide a 16Mbit SPI Flash that allow pages as small as 256 bytes to be written.
The SPI interface will in this case use 6 pins. I have been toying with the idea to create an embedded “disk” that use ca the same footprint as a SO8 as a connector, a 2 pin UART as interface with an offloaded query engine.
The block diagram above illustrates the idea. We use some kind of storage that can be Flash, FRAM, EEPROM, SD Card or maybe a USB stick or even a proper hard-disk. Using an UART as interface we create a query engine capable of storing an retrieving data without the host using it’s time. PSU is basically 3.3V from the host with an added sensor to detect power loss and a super capacitor enabling a few seconds operation so we can Flush SRAM out to the storage.
UART is my preference in this case because it is straight forward and available on every MCU in my target range. USB is seldom accessible and even SPI ports are limited and often needed for other things. Using a crossed TTL Interface directly we have a full duplex communication on several Mbits directly.
I can use the SWD connector I designed earlier for this, but we probably should use a 2.54 pitch 4-wire connector and allow for a few cm of wire. If we add a M2 mounting drill hole we can locate the “disk” on a convenient place.
Using a separate MCU to off-load data storage and retrieval basically work the same way as sending SQL to a server. With a bit of clever query algorithm we should be talking about a read/write time < 1mS almost independent of query complexity or data amount (within reason).
The 3D model above is an early draft of the Embedded Query Engine to get an idea about actual size.. This is based on the STM32F030 and the supecap we used on the motor controller. I copied some diodes as well just to get an idea. This is single side assembly and I prefer to keep this simple. I can probably find smaller supercap and diodes for a start – but as always – work in progress – for now it is just an idea that is funny to play around with. Notice that most of the space is related to the supercap.