Page 1 of 1

DMA buffers declaration

Posted: Mon Apr 30, 2018 12:38 pm
by josesimoes
Hi,

I have a question regarding the best way (or should I say requirement?) to declare the buffers for DMA read/write with SPI or UART drivers.
The samples always have those declared as static byte arrays. I get that because pointers must be passed to the drivers.
The arrays can't be declared as variables inside a function (when using async calls on the drivers), correct?

Questions:
1) would it be OK to use malloc to create those buffers and release them after the driver "transaction" is completed?
2) if the platform is an STM32F7 or STM32H7 are there any further requirements because of memory caching and such?

Thanks in advance!

Re: DMA buffers declaration

Posted: Mon Apr 30, 2018 12:50 pm
by Giovanni
Hi,

You can create buffers anywhere, even in stack frames, as long the variable is "alive" until the operation finishes.

Devices with cache have other restrictions because coherency and/or areas not reachable by DMAs, this is device specific.

Giovanni