cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

STM32H743 Save ADC Output from DMA to RAM to Flash

shahaf321
Associate III

Hi all, im using Cube IDE STM32H743ZI2 Evaluation board

im curently sampling ADC2 and storing the output at an internal array using DMA

the array size is uint16_t[100,000]

my requirements as to store much more data which means i have to use a diffrent memory sector.

i was hoping i could use flash for that matter but the examples that i tried online.

i was wondering is that kind of thing even possible?

do i need some external flash memory for that matter?

my final goal would be storing around 1M samples during about 1-2 seconds  which sums up at about 1Mb

what is the right approach for that matter?

according to the reference manual i should be able to access flash memory via D2->D1 AHB BUS

Thanks! ๐Ÿ™‚

shahaf321_0-1707061080066.png

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
LCE
Principal

You should / must use DMA, and thus can only use RAM for the initial data collection.

Don't forget that flash memory in general has a limited number of write cycles.
So to me it sounds that you should rather use some extra external RAM, which could be accessed directly by the DMA.
But be careful, not all STM32 work with quad / octal SPI PSRAM, so maybe you have to use the FMC with some parallel SRAM.

View solution in original post

5 REPLIES 5

Internal Flash is impractical and slow. Might work for something you plan on recording once, and playing back hundreds of thousands of times, or on a continuous loop.

Data storage with any speed and volume, use eMMC or MicroSD card (SDMMC)

QSPI NOR Flash, designed to read fast, relatively slow to write

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

Ok, i do only need to record once and store the data so that my mcu can proccess the data once it's free.

and i was certain that this MCU can do that seeing it is able to sample and such a high rate (up to 3.6Mhz)

i may pursue the solution of an external Flash with a fast writing ability,

the problem is that i need my data to be continuous, meaning i cant let it be sent over in packs so that i dont lose anything in the data sequence or it's synchronization.

if i do only use the ADC once for about  1M samples. would the flash be able to store it effectively and on time?

do i need to first store it in RAM?

 

Thanks ๐Ÿ™‚

 

LCE
Principal

You should / must use DMA, and thus can only use RAM for the initial data collection.

Don't forget that flash memory in general has a limited number of write cycles.
So to me it sounds that you should rather use some extra external RAM, which could be accessed directly by the DMA.
But be careful, not all STM32 work with quad / octal SPI PSRAM, so maybe you have to use the FMC with some parallel SRAM.

Flash memory, even external, is not writeable!!

In order to write to any flash - you need a special code: it is called "indirect mode". A flash memory could be configured to read from it ("memory mapped mode") or to execute code from it ("XIP mode"). But it is never possible to write to a flash memory (never mind if internal or external) without a special piece of code ("in indirect mode").

So, a DMA cannot work to write to a flash: there is also handshake because writing is much slower as reading: a DMA cannot do.

The only option is:

  • use a DMA and transfer the results to RAM
  • start a special Flash Write procedure which can write your data from RAM to Flash (but without any DMA, in "indirect mode")
  • this can take a long time: make sure you do not get new data to write before you have finished the previous write
  • bear in mind: before you can write random new data - the flash has to be erased: even this can take a lot of time (several milli-seconds)

Flash is a "Read-Only" memory. Just with special procedures it can be erased and written with new content (which can be very slow). Not any DMA can do this (just your own special code with the correct procedure).


@tjaekel wrote:
  • a long time: make sure you do not get new data to write before you have finished the previous write

 


This is a very big problem for my case, in that case i will not pursue the flash option but instead add RAM to my MCU

i've never tried anything like that

how can that be acheived?

and also would the additional RAM be able to connect to DMA?

Thanks! ๐Ÿ™‚