cancel
Showing results for 
Search instead for 
Did you mean: 

Best practices to process and save ADC values into an SD CARD

ALope.1
Associate II

Hello everyone,

I'm trying to build a system where I could read an analog signal and save it into an SD CARD. Besides this, I need to process the signal to activate, or not, the ACC reader for a few seconds.

To save the values, I decided to use two buffers for each peripheral. My idea is to save a mini batch of the raw signals, in fixed intervals, into the SD Card. So, when one buffer is being uploaded to the SD card, the other is being used to recall the values from adc or acc

As beginner in MCU world, I'm looking for some advisers before start the hands-on. I drew the system based on a lot of projects on the internet, but still not sure about the architecture.

The draft of the system is bellow...

Thank you in advance!

This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
2 REPLIES 2
KnarfB
Principal III

Your system diagram makes sense to me. Probably you want to use a file system on the SD card. So you should write in multiples of the block size 512 (?) byte. Being NAND flash, the SD card has an erase block size which is larger (up to 2 MB or more). Keep in mind, that a freshly formatted, unfragmented SD card works best and the time for writing will increase when fragmentation, wear levelling etc.. are coming into play. Is power loss possible in your system? You might want to add a supercap or such to safely finish the last SD card transaction in case of sudden power loss. Power loss can lead to file system corruption. Other reasons may be premature ejection of the SD card by a user. You might have a state LED indicating when its safe to change the card.

just my 5ct

KnarfB

You don't mention which STM32. Use SDIO/SDMMC over SPI

You should use a ping-pong buffer, probably 8KB or more in each half. The ADC should be in a circular mode so this occurs seemlessly without having to restart DMA, etc.

Minimum sector size is 512 bytes, but reading/writing is least efficient due to significant command overhead. FATFS will write up to a cluster.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..