cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Storing data directly in SRAM

bmak
Senior

Hi,

I'm looking for a way to store data directly in SRAM.

You may ask "Why?":

So, my system is collecting data from sensors and writing them to SD card. One full block of data is 128 bytes long. Collecting data and write operation happens when certain trigger happens. I don't want to f_write them every single time, because it simply takes too much time.

How I want to fix my problem:

Performing a f_write operation for bigger chunk of data, like 512 bytes or 1K bytes or even more. I tested my SD card and I could get better performance If I would write more bytes at one time. So basically, my problem comes to storing "a few" blocks of my data (one block = 128 bytes) and then flushing all of them to SD card directly.

How I want to do that?

I would like to store this data in SRAM, since I have 192 Kbytes of space.

I was thinking about using DMA Memory-To-Memory. I even found an example on how to do that: https://electronics.stackexchange.com/questions/543555/memory-to-memory-dma-on-stm32

But, I'm not sure if this is what I'm looking for. I dont want to copy one array to another. I would like to create (for example) an array which could contain 4,8,12,... blocks of my data and then refer to it when writing to SD card, but the array would be placed in SRAM so it wouldn't take space from my stack.

Please help me If my direction of thinking is right, or show me the way, or what tools to look for. I know what I want to use, but I'm not sure how to do that.

I'm using STM32F407.

Thanks!

Edit:

After testing my SD card I decided that I would like to write block of data of size 16KB at one f_write operation.

10 REPLIES 10
gbm
Lead III

Everything not bigger than 100% is not too much. That's what the memory usage report is for. You may only use up to 100% of memory and not a single byte more than that. There is no magic involved. ;)

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice